窗口类API函数测试题
本题考查了FindWindowEx、GetParent、GetNextWindow这3个API函数的理解和掌握程度。
假设有一个窗口的句柄结构树如下图所示:
运行下面的Test()过程,立即窗口中的4个结果分别是什么?
读者可以把自己的答案回复本帖,也可以加QQ群61840693与题目作者交流。
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDLAST = 1
Private Const GW_HWNDNEXT = 2
Private Const GW_HWNDPREV = 3
Sub Test()
Dim h(0 To 10) As Long
h(0) = 264990
h(1) = FindWindowEx(h(0), 264988, "Button", vbNullString)
h(2) = GetParent(h(0))
h(3) = GetNextWindow(264988, GW_HWNDPREV)
h(4) = GetNextWindow(264988, GW_HWNDFIRST)
Debug.Print h(1), h(2), h(3), h(4)
End Sub