100分,求vb EnumChildWindows,EnumChildProc实例源程序
主要是这两个函数的用法。要解决的问题:我已经知道父窗体的名字了,并且已取得句柄。如何通过遍历子窗体,取得子窗体的句柄,并且将这些句柄保存在一个数组中……多谢了邮箱:939...
主要是这两个函数的用法。要解决的问题:我已经知道父窗体的名字了,并且已取得句柄。
如何通过遍历子窗体,取得子窗体的句柄,并且将这些句柄保存在一个数组中……多谢了
邮箱:939813822@qq.com 展开
如何通过遍历子窗体,取得子窗体的句柄,并且将这些句柄保存在一个数组中……多谢了
邮箱:939813822@qq.com 展开
1个回答
展开全部
窗体代码如下 添加一个按钮 一个list控件
Private Sub Command1_Click()
EnumChildWindows GetDesktopWindow, AddressOf EnumChildProc, ByVal 0&
End Sub
模块代码如下
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String * 255
GetWindowText hwnd, sSave, 255
If Blank(sSave) <> "" Then Form1.List1.AddItem hwnd & "," & sSave
EnumChildProc = 1
End Function
Public Function Blank(ByVal szString As String) As String
Dim l As Integer
l = InStr(szString, Chr(0))
If l > 0 Then
Blank = Left(szString, l - 1)
Else
Blank = szString
End If
End Function
Private Sub Command1_Click()
EnumChildWindows GetDesktopWindow, AddressOf EnumChildProc, ByVal 0&
End Sub
模块代码如下
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String * 255
GetWindowText hwnd, sSave, 255
If Blank(sSave) <> "" Then Form1.List1.AddItem hwnd & "," & sSave
EnumChildProc = 1
End Function
Public Function Blank(ByVal szString As String) As String
Dim l As Integer
l = InStr(szString, Chr(0))
If l > 0 Then
Blank = Left(szString, l - 1)
Else
Blank = szString
End If
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询