EditHwnd = FindWindowEx(351223, 0&, "TA2Edit", vbNullString)
Text3.Text = EditHwnd
TA2Edit是类名,问题是,现在有两个类名相同,只能找出一个怎么办啊?
Text3.Text = EditHwnd
TA2Edit是类名,问题是,现在有两个类名相同,只能找出一个怎么办啊?
Text4.Text = EditHwnd2
EditHwnd:子窗口句柄。查找从在Z序中的下一个子窗口开始。
Private Declare Function GetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As LongConst GW_CHILD = 5
Const GW_HWNDNEXT = 2
Dim childRen() As Long
Private Sub Command1_Click()
Dim buf As String
Dim buflen As Long
Dim Num_Children As Long
Dim Child_hWnd As LongNum_Children = 0
Child_hWnd = GetWindow(351223, GW_CHILD) '取得第 1 个子窗口的句柄Do While Child_hWnd <> 0 '如果有子窗口
buflen = 256
buf = Space$(buflen - 1) buflen = GetClassName(Child_hWnd, buf, buflen)
buf = Left$(buf, buflen) '取得子窗口的类名
If Right(buf, 7) = "TA2Edit" Then '判断是否为地址栏子窗口,v如果是,将句柄放入children数组中
Num_Children = Num_Children + 1
ReDim Preserve childRen(1 To Num_Children)
childRen(Num_Children) = Child_hWnd
End If
Child_hWnd = GetWindow(Child_hWnd, GW_HWNDNEXT)
Loop
'**********读取所有有效句柄
For i = 1 To UBound(childRen)
MsgBox childRen(i)
NextEnd Sub'*************************以上代码具有想同的功能
[\code]