Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 131,725 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,344 people online right now. Registration is fast and FREE... Join Now!




SetCapture, ReleaseCapture not working under Win2k3 and XP

 
Reply to this topicStart new topic

SetCapture, ReleaseCapture not working under Win2k3 and XP, Form has webBrowser control. Attempt to capture mouse events fails. re

Petebardo
post 15 Dec, 2006 - 02:47 PM
Post #1


New D.I.C Head

*
Joined: 14 Dec, 2006
Posts: 12


My Contributions


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
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 10:20AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month