Hallo Stefan
Ich hatte bis vor etwa 10min das selbe Problem, nämlich dass immer alle Fenster angezeigt worden sind in der ListBox. Hier nun das korrekte Beispiel:
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
| function EnumWinProc(Wnd: hWnd; Frm: TForm1): Boolean; Export; StdCall; var WinText: Array[0..255] of Char; pRect:TRect; begin GetWindowText(Wnd, WinText, 255); GetWindowRect(Wnd, pRect); Result := True; if (StrPas(WinText) <> '') then begin if GetWindow(Wnd, GW_CHILD) <> 0 then begin if pRect.Left > 0 then begin if (GetWindowLong(Wnd, GWL_STYLE) and WS_VISIBLE) <> 0 then begin Frm.ListBox1.Items.Add(IntToStr(Wnd) + ': ' + StrPas(WinText)); end; end; end; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin ListBox1.Items.Clear; EnumWindows(@EnumWinProc, LongInt(self));
end; |
Der Vorteil von diesem Code ist auch, dass die Maximierten Fenster auch gleich ausgeschaltet werden, das heisst, nicht angezeigt werden.
Der Entscheidenede Code ist aber der:
Quelltext
1:
| if (GetWindowLong(Wnd, GWL_STYLE) and WS_VISIBLE) <> 0 then |
Man, bis ich das rausgefunden hatte....hat mich eine schöne Zeit gekostet
Ich hoffe, dir ist damit auch geholfen....
Greets Rooof
Jedes Problem ist lösbar, wenn du dich nicht von deinem eigenen Denken und von deinem eigenen Verstand leiten lässt...