Solved

SetCapture and VB2003

Posted on 2006-11-30
4
422 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 86

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 86

Accepted Solution

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

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

627 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