Solved

SetCapture and VB2003

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

11 Experts available now in Live!

Get 1:1 Help Now