This code works for Win2k, but not for XP and Win2k3:
Module declaration:
CODE
Public Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetCapture Lib "user32" () As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long
In the form:
CODE
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
SetCapture (Me.hwnd)
SetCursorPos WebBrowser1.width, WebBrowser1.height
ShowCursor False
End Sub
I've tried SetCapture (Me.hWnd) in the form_load as well, but no luck. Mouse events were not sent to the form.
I placed this in the form_load:
CODE
If Not SetCapture(Me.hwnd) Then
MsgBox "Unable to Capture Mouse." + vbCrLf + _
"Me = " + Str(Me.hwnd) + vbCrLf + _
"Captured = " + Str(GetCapture())
End If
The message is always displayed. Me.hWnd and GetCapture() show the same value.
Note: In order to make it work in Win2k, I had to place the SetCapture in the WebBrowser1_DocumentComplete event code.
This post has been edited by Petebardo: 15 Dec, 2006 - 04:05 PM