古詩詞大全網 - 成語故事 - 關於VB的FindWindowsEx的,高人進

關於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)