![]() |
Re: [DELPHI 2010] EnumWindows mit Handle
Ok, nun habe ich selbstständig versucht, das in einer ListView umzusetzen!
function EnumWinProc(Wnd: THandle; LParam: LongInt): Boolean; stdcall; var WinCaption : string; Len: integer; i : TListItem; begin Result := True; Len := GetWindowTextLength(Wnd); SetLength(WinCaption, Len); GetWindowText(Wnd, PChar(WinCaption), Len+1); if Trim(WinCaption) <> '' then begin i:= Form1.ListView1.Items.Add; i.Caption:= WinCaption; i.SubItems.add(inttostr(Wnd)); end; end; Funktioniert natürlich nicht, ist ja klar :? 1. Spalte: Fenstername 2. Spalte: Handle Wie muss ich mein Code umsetzen? Oder muss ich das ganz anders machen mit irgendwas wie
Delphi-Quellcode:
oder sowas?
for I:= 0 to WindowCount do begin
|
Re: [DELPHI 2010] EnumWindows mit Handle
Hast du den Code eigentlich verstanden?
Zitat:
Delphi-Quellcode:
Wobei LParam das LParam aus dem Aufruf von EnumWindows enthält
function EnumWindowsProc(wHandle: HWND; LParam: LongInt): Bool; stdcall;
Code:
Also, alles was du per LParam übergibst, hast du somit auch in der Prozedur
EnumWindows(@EnumWindowsProc, [color=#ff0000]LongInt(ListBox1)[/color]);
function EnumWindowsProc(wHandle: HWND; [color=#ff0000]LParam: LongInt[/color]): LongBool; stdcall; begin [color=#ff0000]TListView(LParam)[/color].Item.Add und mußt es einfach nur zurückcasten. (Wobei man hierbei auch mal den Prozedurrumpf anpassen könnte, so wie es in der Demo gemacht wurde Sowas wie Form1.ListView1 verursacht nur mehr Verwirrung und erzeugt fehleranfälligeren Code. PS: Boolean (1 Byte) <> BOOL (4 Byte) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:59 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz