Function Reference


_WinAPI_GetAncestor

Retrieves the handle to the ancestor of the specified window

#include <WinAPISysWin.au3>
_WinAPI_GetAncestor ( $hWnd [, $iFlags = 1] )

Parameters

$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.

Return Value

Returns the handle of the ancestor window

Remarks

Above constants require #include <WindowsConstants.au3>

Related

_WinAPI_GetParent

See Also

Search GetAncestor in MSDN Library.

Example

#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