关于VB的FindWindowsEx的,高人进
一、给你一个查找第N个控件hwd的函数:
Function FindWnd(Phwnd As Long, ClassName As String, Index) As Long
Dim i As Integer, ChildHwnd As Long
ChildHwnd = FindWindowEx(Phwnd, 0, ClassName, vbNullString)
Do While ChildHwnd
i = i + 1
If i = Index Then
FindWnd = ChildHwnd
Exit Do
End If
ChildHwnd = FindWindowEx(Phwnd, ChildHwnd, ClassName, vbNullString)
Loop
End Function
二、函数调用举例:
如果你要查找计算器内第4个"Button",且不管其标题,那么这样调用:
dim i as long,Phwnd as long
Phwnd = FindWindow(vbNullString, "计算器")
i=FindWnd(Phwnd, "Button", 4)