检索指定窗口的祖句柄
#Include <WinAPI.au3>
_WinAPI_GetAncestor($hWnd [, $iFlags = 1])
$hWnd | 检索的祖窗口句柄. 如果为桌面窗口, 函数返回 0. |
$iFlags | [可选参数] 指定要检索的祖窗口.参数可以是以下值之一: $GA_PARENT - 检索父窗口 $GA_ROOT - 检索父窗口活链接的根窗口 $GA_ROOTOWNER - 检索父窗口链拥有的根窗口与 GetParent 返回的所有者窗口. |
成功: | 返回祖先窗口句柄 |
失败: | 返回 0 |
在MSDN中搜索
#include <WinAPI.au3>
#include <WindowsConstants.au3>
_Main()
Func _Main()
Local $hwnd, $hparent
$hwnd = GUICreate("test")
$hparent = _WinAPI_GetAncestor($hwnd, $GA_PARENT)
MsgBox(4096, "Parent", "Get Ancestor of " & $hwnd & ": " & $hparent)
MsgBox(4096, "Root", "Get Ancestor of " & $hparent & ": " & _WinAPI_GetAncestor($hwnd, $GA_ROOT))
MsgBox(4096, "Root Owner", "Get Ancestor of " & $hparent & ": " & _WinAPI_GetAncestor($hwnd, $GA_ROOTOWNER))
EndFunc ;==>_Main