function GetText(Wnd: HWND): string;
var
textlength: Integer;
Text: PChar;
begin
textlength := SendMessage(Wnd, WM_GETTEXTLENGTH, 0, 0);
if textlength = 0 then Result := ''
else
begin
GetMem(Text, textlength + 1);
SendMessage(Wnd, WM_GETTEXT, textlength + 1, Integer(Text));
Result := Text;
FreeMem(Text);
end;
end;
function EnumWindowsProc(Wnd: HWND; lParam: lParam): BOOL; stdcall;
begin
Result := True;
if (IsWindowVisible(Wnd) ) and
((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
(GetWindowLong(Wnd, GWL_HWNDPARENT) = GetDesktopWindow)) and
(GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW = 0) then begin
//ShowWindow(wnd, SW_Show); // Taskbar vertecken
form1.Listbox2.Items.add(IntToStr(Wnd));
if IsIconic(wnd) then begin
{versteckt}
Form1.Listbox1.Items.Add('
Handle: ' + IntToStr(Wnd) + ',Text: ' + GetText(Wnd) + ' Versteckt!')
end
else
begin
Form1.Listbox1.Items.Add('
Handle: ' + IntToStr(Wnd) + ',Text: ' + GetText(Wnd) + ' Sichtbar!');
end;
end;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Param: Longint;
begin
listbox1.Clear;
EnumWindows(@EnumWindowsProc, Param);
end;