Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SetCapture and VB2003

Posted on 2006-11-30
4
Medium Priority
?
423 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 2000 total points
ID: 18049095
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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