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
| function EnumWindowsProc(Wnd: HWND; lParam: lParam): BOOL; stdcall;
function GetText(Wnd: HWND): String;
var
nTextLength: Integer;
Text: PChar;
begin
nTextLength := SendMessage(Wnd, WM_GETTEXTLENGTH, 0, 0);
if nTextLength = 0 then
Result := ''
else
begin
GetMem(Text, nTextLength + 1);
SendMessage(Wnd, WM_GETTEXT, nTextLength + 1, Integer(Text));
Result := Text;
FreeMem(Text);
end;
end;
begin
Result := True;
if(IsWindowVisible(Wnd) or IsIconic(wnd)) and ((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or (GetWindowLong(Wnd, GWL_HWNDPARENT) = Int(GetDesktopWindow))) and (GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW = 0) then
begin
MainForm.RichEdit.Lines.Add(' Handle : ' + FormatFloat('#0000000,000', Wnd) + ',' + #9 + 'Titre : ' + GetText(Wnd));
Inc(MainForm._nNbFen);
end;
end;
// Pour appeller.
EnumWindows(@EnumWindowsProc, Param); |
Partager