100分,求vb EnumChildWindows,EnumChildProc实例源程序
来源:百度知道 编辑:UC知道 时间:2024/06/03 22:59:24
如何通过遍历子窗体,取得子窗体的句柄,并且将这些句柄保存在一个数组中……多谢了
邮箱:939813822@qq.com
窗体代码如下 添加一个按钮 一个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(szStri