Solved

SetCapture and VB2003

Posted on 2006-11-30
4
408 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now