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]