Einzelnen Beitrag anzeigen

bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.121 Beiträge
 
Delphi 11 Alexandria
 
#1

GetWindow Unterschiede FMX und VCL

  Alt 18. Jul 2020, 22:30
mit dem Code (Quelle: https://www.swissdelphicenter.ch/en/showcode.php?id=327 kann ein Fenster über seinen Namen gesucht werden , ging unter VCL prima.
Unter FMX kann die Zeile GetWindow(Application.Handle, GW_HWNDFIRST); nicht mehr kompiliert werden, wie Lautet die Lösung .... auch UNIX fähig dann ?


Delphi-Quellcode:
function FindWindowByTitle(WindowTitle: string): Hwnd;
var
  NextHandle: Hwnd;
  NextTitle: array[0..260] of char;
begin
  // Get the first window
  NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
  while NextHandle > 0 do
  begin
    // retrieve its text
    GetWindowText(NextHandle, NextTitle, 255);
    if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
    begin
      Result := NextHandle;
      Exit;
    end
    else
      // Get the next window
      NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
  end;
  Result := 0;
end;
  Mit Zitat antworten Zitat