Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Oberstes Fenster einer Applikation ermitteln (https://www.delphipraxis.net/163129-oberstes-fenster-einer-applikation-ermitteln.html)

DeddyH 16. Sep 2011 11:11


Oberstes Fenster einer Applikation ermitteln
 
Ich möchte ermitteln, welches Fenster eines bestimmten Programms in der Z-Order zuoberst steht, und zwar unabhängig vom Typ. Das Handle des Hauptfensters habe ich, weiterhin das eines modalen Dialogs, und möchte nun wissen, ob dieser Dialog evtl. von einem anderen Fenster derselben Applikation verborgen wird. Alle meine Versuche mit GetWindow oder GetTopWindow waren bislang nicht von Erfolg gekrönt, da diese "typabhängig" arbeiten.
Zitat:

GW_HWNDFIRST

The retrieved handle identifies the window of the same type that is highest in the Z order.

If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window.
Was übersehe ich da bloß?

[edit] So scheint es zu funktionieren:
Delphi-Quellcode:
function IsAppTopWindow(aWnd: HWnd; aThreadID: DWORD): Boolean;
var
  NextWnd: HWnd;
  NextThreadID: DWORD;
begin
  Result := true;
  NextWnd := GetWindow(aWnd, GW_HWNDPREV);
  while Result and (NextWnd <> 0) do
    begin
      NextThreadID := GetWindowThreadProcessID(NextWnd);
      if (NextThreadID = aThreadID) and IsWindowVisible(NextWnd) then
        Result := false
      else
        NextWnd := GetWindow(NextWnd, GW_HWNDPREV);
    end;
end;
Wer will, kann die ThreadID des übergebenen Fensters auch innerhalb der Funktion ermitteln, ich hatte das bereits erledigt. [/edit]


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz