‘-Api Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Public Const GW_CHILD As Long = 5 Public Const GW_HWNDNEXT As Long = 220 ‘---找自身窗体Webbrowser的句柄------------------------------------------- Public Function FindWebPage(ByVal hParentWnd As Long) As Long Dim strClassName As String * 30 Dim hTempWnd As Long hTempWnd = GetWindow(hParentWnd, GW_CHILD) Do While (hTempWnd <> 0) strClassName = "" GetClassName hTempWnd, strClassName, 30 Debug.Print strClassName If Left(strClassName, Len("Internet Explorer_Server")) = "Internet Explorer_Server" Then WebhWnd = hTempWnd ‘--find FindWebPage = WebhWnd Exit Function End If FindWebPage = FindWebPage(hTempWnd) ‘没找到,继续 If FindWebPage <> 0 Then Exit Function End If hTempWnd = GetWindow(hTempWnd, GW_HWNDNEXT) Loop End Function
时间: 2024-10-23 06:09:39