I have tried to stop the mouse moving under certain circumstances (clicking and draging the scene). But when I do, the mouse "jumps" to a different position initially. I'm doing it as part of the VB code, anyone see my problem?
This is the Mouse module, which incorporates the calls to movingthe mouse programmatically:
Module mouse
'Option Explicit
Public Declare Sub Mouse_Event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As POINTAPI) As Long
Public Const MOUSEEVENTF_LEFTDOWN As Integer = &H2
Public Const MOUSEEVENTF_LEFTUP As Integer = &H4
Public Const MOUSEEVENTF_MIDDLEDOWN As Integer = &H20
Public Const MOUSEEVENTF_MIDDLEUP As Integer = &H40
Public Const MOUSEEVENTF_RIGHTDOWN As Integer = &H8
Public Const MOUSEEVENTF_RIGHTUP As Integer = &H10
Public Const MOUSEEVENTF_MOVE As Integer = &H1
Public Structure POINTAPI
Dim X As Long
Dim Y As Long
End Structure
Public Function GetCurrentX() As Long
Dim Position As POINTAPI
GetCursorPos(Position)
GetCurrentX = Position.X
End Function
Public Function GetCurrentY() As Long
Dim Position As POINTAPI
GetCursorPos(Position)
GetCurrentY = Position.Y
End Function
Public Sub LeftClick()
LeftDown()
LeftUp()
End Sub
Public Sub LeftDown()
Mouse_Event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
End Sub
Public Sub LeftUp()
Mouse_Event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub
Public Sub MiddleClick()
MiddleDown()
MiddleUp()
End Sub
Public Sub MiddleDown()
Mouse_Event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
End Sub
Public Sub MiddleUp()
Mouse_Event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
End Sub
Public Sub MoveMouse(ByVal xMove As Long, ByVal yMove As Long)
Mouse_Event(MOUSEEVENTF_MOVE, xMove, yMove, 0, 0)
End Sub
Public Sub RightClick()
RightDown()
RightUp()
End Sub
Public Sub RightDown()
Mouse_Event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
End Sub
Public Sub RightUp()
Mouse_Event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
End Sub
End Module
In the MouseDown event of the DBPro container, I save the coordinates:
MouseLastX = e.X
MouseLastY = e.Y
and in the MouseMove event, I keep moving the mouse back from whence it came:
SetCursorPos(MouseLastX, MouseLastY)