1,485
社区成员
发帖
与我相关
我的任务
分享
Dim w As New clsWindow
If w.GetWindowHwndByTitleEx("应用程序标题栏文字") > 0 Then
MsgBox w.GetElementHwndByClassName("Internet Explorer_Server") '得到ie控件句柄
End If
'┏〓〓〓〓〓〓〓〓〓 FindHwndByClassAndId,start 〓〓〓〓〓〓〓〓〓┓
'[简介]:
'查找窗体中多层次下第几个相同类的句柄
Function FindHwndByClassAndId(WinHwnd As Long, ByVal Class As String, Optional FindId As Integer, Optional Id As Integer) As Long
'[mycode_id:1934],edittime:2011/8/3 3:30:07
Dim Hwnd2 As Long
Dim FindHwnd As Long, TempFindHwnd As Long
Hwnd2 = GetWindow(WinHwnd, GW_CHILD)
While FindHwnd = 0 And Hwnd2 > 0
If GetClass(Hwnd2) = Class Then
TempFindHwnd = Hwnd2
If Id = FindId Then
FindHwnd = TempFindHwnd
GoTo DoEnd
Else
Id = Id + 1
End If
End If
FindHwnd = FindHwndByClassAndId(Hwnd2, Class, FindId, Id)
Hwnd2 = GetWindow(Hwnd2, GW_HWNDNEXT)
Wend
DoEnd:
FindHwndByClassAndId = FindHwnd
End Function
'┗〓〓〓〓〓〓〓〓〓 FindHwndByClassAndId,end 〓〓〓〓〓〓〓〓〓┛