lst:TStringList;
{$R *.dfm}
function EnumWndProc(AWnd: HWND; AlParam: LPARAM):Boolean;stdcall;
var
WndCaption: array[0..254] of Char;
str:string;
begin
GetWindowText(AWnd, @WndCaption, 254);
if WndCaption[0]<>chr(0) then
begin
str:=Trim(string(WndCaption));
if str='Form1' then
begin
lst.Add(IntToStr(AWnd));
Form1.ListBox1.Items.Add(Format('%d = %s',[AWnd,StrPas(WndCaption)]));
end;
end;
Result := True;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
h:Thandle;
i:integer;
begin
lst:=TStringList.Create;
try
EnumWindows(@EnumWndProc,0);
for i:=0 to lst.Count-1 do
begin
h:=FindWindowEx(strtoint(lst.Strings[i]),0,'Tpanel',nil);
if h>0 then
begin
ShowMessage(IntToStr(h));
end;
end;
finally
lst.Free;
end;
end;