Retrieves the handle to the ancestor of the specified window
#include <WinAPISysWin.au3>
_WinAPI_GetAncestor ( $hWnd [, $iFlags = 1] )
$hWnd | Handle to the window whose ancestor is to be retrieved. If this is the desktop window, the function returns 0. |
$iFlags | [optional] Specifies the ancestor to be retrieved. This parameter can be one of the following values: $GA_PARENT - Retrieves the parent window $GA_ROOT - Retrieves the root window by walking the chain of parent windows $GA_ROOTOWNER - Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent. |
Above constants require #include <WindowsConstants.au3>
Search GetAncestor in MSDN Library.
#include <MsgBoxConstants.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
Local $hWnd, $hParent
$hWnd = GUICreate("test")
$hParent = _WinAPI_GetAncestor($hWnd, $GA_PARENT)
MsgBox($MB_SYSTEMMODAL, "Parent", "Get Ancestor of " & $hWnd & ": " & $hParent)
MsgBox($MB_SYSTEMMODAL, "Root", "Get Ancestor of " & $hParent & ": " & _WinAPI_GetAncestor($hWnd, $GA_ROOT))
MsgBox($MB_SYSTEMMODAL, "Root Owner", "Get Ancestor of " & $hParent & ": " & _WinAPI_GetAncestor($hWnd, $GA_ROOTOWNER))
EndFunc ;==>Example