用GetWindow枚举子窗口句柄的问题
各位大侠,近日突然发现 用GetWindow枚举子窗口句柄出问题了,得到的句柄值都很小,与实际的不相符,这是怎么回事?
附上我的vb代码:
期盼大侠们指点迷津。。。。。。。。。。。。。。
附上我的vb代码:
Option Explicit
Public Const GW_CHILD = 5
Public Const GW_HWNDNEXT = 2
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Integer) As Integer
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
'枚举某一个窗口的子窗口
Public Sub ListAllChildWindow(Optional bParentHwnd As Long)
On Error Resume Next
Dim Str As String * 256 '定义str用来存储子窗体类名
Dim hd As Long, w2 As String
If bParentHwnd = 0 Then bParentHwnd = GetDesktopWindow '桌面hwnd
hd = GetWindow(bParentHwnd, GW_CHILD) '获取Form的第一个子窗体句柄hd
Do While hd <> 0 '如果子窗体查找完毕hd返回0,所以用hd<>0作为继续查找条件
GetClassName hd, Str, 256 '获得子窗体类名存储在str里
w2 = Left$(Str, InStr(Str, Chr$(0)) - 1)
Debug.Print w2 & "----" & hd
hd = GetWindow(hd, GW_HWNDNEXT) '获取下一个同级子窗体句柄hd
Loop
End Sub
Sub Test()
ListAllChildWindow Me.Hwnd
End Sub
’下面是得到的结果:
'ThunderTextBox ----3996(正确的hwnd: 23728126)
'ThunderTextBox ----4094(正确的hwnd: 8195996)
'ThunderCommandButton ----3862
期盼大侠们指点迷津。。。。。。。。。。。。。。
...全文
相关推荐
C# Windows API应用之基于GetDesktopWindow获得桌面所有窗口句柄的方法
主要介绍了C# Windows API应用之基于GetDesktopWindow获得桌面所有窗口句柄的方法,结合实例形式分析了GetDesktopWindow函数用于获取窗口句柄的具体使用方法与相关注意事项,需要的朋友可以参考下
winspy获取win32窗口句柄
获取windows32窗口句柄 可作为模板自定义参数
VC中获取窗口句柄的各种方法
VC中获取窗口句柄的各种方法
C#查找窗口句柄的方法
C#查找窗口句柄,方便操作窗口。传递数据等。用windows API。WINDOWS上的好资源,早下载早受益。做开发离不了。
枚举窗口的源代码资源
枚举窗口 枚举窗口 枚举窗口 枚举窗口 枚举窗口


API
