码迷,mamicode.com
首页 > Windows程序 > 详细

窗体内查找webbrowser控件的句柄

时间:2014-11-24 20:36:21      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   sp   on   div   log   

-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

 

窗体内查找webbrowser控件的句柄

标签:style   blog   io   ar   color   sp   on   div   log   

原文地址:http://www.cnblogs.com/iseaside/p/4119487.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!