Autor Beitrag
cbs
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207
Erhaltene Danke: 1



BeitragVerfasst: Mi 12.06.02 20:29 
hi, und nen schönen guten abend!

Ich fand das DelphiForum richtig klasse. So wie es aussieht habt ihr hier ne gute basis auch so erfolgreich zu werden (vielleicht noch besser (ich geh davon aus *g*)). Also nischt wie rann und fragen stelln (und natürlich sinnvolle antworten geben).

Hier meine frage: ich hab das handle einer anwendung. Sonst nichts (ok den titel der anwendung). Gibt es eine möglichkeit alle handle’s der formulare sie erfahren (natürlich nur die die offen sind)?

Wenn ich z.b. über eine function (aus ner faq) das handler meiner eigenen anwendung ermittle (über den fenstertitel) bekomme ich das handle von TApplication und nicht das handle von meinem Form1 (oder welches formular auch immer).

Mir geht es in erster linie darum die handles fremder anwendungen (derer formulare) zu ermitteln. Also das beispiel oben is eben nur nen beispiel (ich weiß das man das handle mit form1.handle rausbekommt). Wäre toll wenn jemand von euch ne ahnung hat oder zumindest nen anhaltspunkt. mitter winapi bin ich nich so angefreundet. Danke schon mal.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mi 12.06.02 22:00 
Hi,

Die EnumThreadWindows API listet dir alle zu einem Thread
gehörenden Fenster auf.

Zitat:
The EnumThreadWindows function enumerates all nonchild windows associated with a thread by passing the handle of each window, in turn, to an application-defined callback function. EnumThreadWindows continues until the last window is enumerated or the callback function returns FALSE.


Hier ein Beispiel:
(nicht optimiert)

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
function EnumProc(aWnd: HWND; var wnd: HWND): BOOL; stdcall;
var
  buffer: array[0..100] of Char;
begin
  Result := True;
  if IsWindowVisible(aWnd) then
  begin
    GetClassName(aWnd, buffer, SizeOf(buffer));
    Form1.Memo1.Lines.Add('Klassenname: '+ string(buffer)+ '- Handle: ' + Inttostr(aWnd));
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  wnd: HWND;
begin
  wnd := 0;
  EnumThreadWindows(GetCurrentThreadID, @EnumProc, Integer(@wnd));
end;
cbs Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207
Erhaltene Danke: 1



BeitragVerfasst: Fr 14.06.02 15:37 
Titel: Funktioniert leider net
Danke erstmal für deine hilfe. ich weiß nicht ob ich dafür zu doof bin aber irgendwie funktioniert das ganze nicht.
Zitat:
Die EnumThreadWindows API listet dir alle zu einem Thread
gehörenden Fenster auf.

Sind Thread's nicht eigentständige Programmteile die unabhängig vom hauptprogramm laufen? was is wenn ich keine threads habe. sondern eben nur meinen anwendungs-prozess? Welches handle muss ich da jetzt genau übergeben?

du schreibst in deinem beispiel
Zitat:
EnumThreadWindows(GetCurrentThreadID, ...)

muß ich bei GetCurrentThreadID das handle meiner anwendung übergeben? oder welches handle? wie gesagt ich bekomme keine liste mit handles wie es dein beispiel vermuten lassen würde.

danke schon mal
d3g
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Do 20.06.02 21:06 
Hi cbs,

wenn du zu einer Frage zu einer Windows-API-Funktion oder -Struktur hast, kannst du bei msdn.microsoft.com/library/ danach schauen.

Zu GetCurrentThreadId steht da:

Zitat:
The GetCurrentThreadId function retrieves the thread identifier of the calling thread.

Du kannst den Code also so lassen.

MfG,
d3g

_________________
One OS to rule them all, one OS to find them.
One OS to brimng the all and in the darkness bind them.
cbs Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207
Erhaltene Danke: 1



BeitragVerfasst: Do 20.06.02 22:55 
ok .. danke euch beiden, ich werd mal noch nen bischen dran rumfummeln vieleicht erreiche ich was... wenns funzt werde ich selbstverständlich nicht zögern die lösung meines problems der welt preiszugeben :wink: