Solved

SetCapture and VB2003

Posted on 2006-11-30
4
419 Views
Last Modified: 2010-05-18
Seems I am unable to get SetCapture to work with vb 2003.

"'hwnd' is not a member of 'WindowsApplication1.Form1'.
*****************************************************************

Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function GetCapture Lib "user32" () As Long
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
    Const MOUSEEVENTF_LEFTDOWN = &H2

    Private Sub Form_Activate()
        Print("Left-Click to SetCapture")
        Print("Right-Click to ReleaseCapture")
    End Sub

    Private Sub Form_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        If Button = 1 Then
            If GetCapture <> Me.hwnd Then SetCapture(Me.hwnd)
            ' Press and then *do not* release the left mouse button.
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        Else
            ReleaseCapture()
        End If
    End Sub

End Class
0
Comment
Question by:TechMonster
  • 2
  • 2
4 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18048282
All of your declarations are for VB6...

Change "Long" to "Integer" in all cases.

You can use "IntPtr" for vars declared as hWnd if you want.
0
 

Author Comment

by:TechMonster
ID: 18048501
Changed all Long datatypes to Integer.  

    Private Sub Form_Mousedown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
        GetCapture()
        MsgBox(GetCapture().ToString)
        If Button = 1 Then
            If GetCapture <> Me.intptr Then SetCapture(Me.intptr)<----Still have issues with this section******
             Press and then *do not* release the left mouse button.
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        Else
            ReleaseCapture()
            Beep()
        End If
    End Sub
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 18049095
0
 

Author Comment

by:TechMonster
ID: 18103255
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question