有什么代码???一有关于它句柄的代码无论什么就出错啊!!!例如a=WebBrowser1.Hwnd就OVER

解决方案 »

  1.   

    Webbrowser Control 没有 Hwnd 属性 !!!
    请看:
    http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reflist_vb.asp另外, MSDN 上已有 这个问题的说明:PRB: Obtaining the HWND for the WebBrowser Control (Q244310)
    http://support.microsoft.com/default.aspx?scid=kb;en-us;Q244310
      

  2.   

    那怎么办???我需要HWND属性啊!!!
      

  3.   

    sonicdater(发呆呆(我答问题*不吵架*因为我呆))
    已经提供解决方法了:Visual Basic developers can use the following code, which takes the HWND of the hosting form and examines all its children until it finds the window with a window class of "Shell Embedding". This is the topmost window of the WebBrowser control. CAUTION: The Internet Explorer window class name may change in future browser versions. Use this workaround with care. 
       Option Explicit   Public Const GW_HWNDNEXT = 2
       Public Const GW_CHILD = 5
       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 LongPublic Function GetBrowserWindow(hwndBrowserContainer As Long) As Long
        Dim RetVal As Long
        Dim Result As Long
        Dim hwndChild, hwndPeer As Long
        Dim ClassString As String * 256
         
          
        hwndPeer = GetWindow(hwndBrowserContainer, GW_CHILD)
        While (Result = 0) And (hwndPeer <> 0)
            hwndPeer = GetWindow(hwndPeer, GW_HWNDNEXT)
            RetVal = GetClassName(hwndPeer, ClassString, 256)
            If hwndPeer <> 0 Then
                RetVal = GetClassName(hwndPeer, ClassString, 256)
                If Left$(ClassString, InStr(ClassString, Chr$(0)) - 1) = "Shell Embedding" Then
                    Result = 1
                End If
            End If
        Wend
                    
        GetBrowserWindow = hwndChild
    End Function
    Please note that neither of these techniques are needed when you automate Internet Explorer. For automation, C++ and Visual Basic users can both use the HWND property of the InternetExplorer object.
      

  4.   

    可以取得窗口内的一个控件的HWND是吗??谢谢了
      

  5.   

    你说的是IE内的工具栏这样控件还是页面里面的控件,如果是后者可能无法获得,如果是前者,理论上获得窗口局柄就可以获得里面的控件的局柄,不过我没有试过在IE中的编程
      

  6.   

    x = Screen.Width / Screen.TwipsPerPixelX \ 2
    y = (Screen.Height / Screen.TwipsPerPixelX) \ 2
    SetCursorPos x, y  '把鼠标移到WEBBROWSER上
    GetCursorPos point 
    hwnd = WindowFromPoint(point.x, point.y)  '获得鼠标下面的窗体的句柄
      

  7.   

    TO:LOU_DF(ldf)
    有效吗?
    WindowFromPoint是API
    还是VB自带函语句?
      

  8.   

    WindowFromPoint
    SetCursorPos 
    GetCursorPos 
    都是 win32 api .你还是 照着 微软的 方法做吧