I'd like to know if it's possible to lock the mouse in a form. I mean : I'd like the mouse cursor to be invisible ( i know the code ) and i'd like the user can only use the keyboard... how can i do ??
Thanks
COSIDUS
Printable View
I'd like to know if it's possible to lock the mouse in a form. I mean : I'd like the mouse cursor to be invisible ( i know the code ) and i'd like the user can only use the keyboard... how can i do ??
Thanks
COSIDUS
To disable the Mouse
To Hide/Show the cursor:Code:Shell "rundll32 mouse,disable"
Code:Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Sub Command1_Click()
'Hide the cursor
ShowCursor 0
End Sub
Private Sub Command2_Click()
'Show the cursor
ShowCursor 1
End Sub
and how can i lock one mouse button?
i would like that only the left button works!
is that possible?
thank you...
If your form does not have a popup menu, why not try your first suggestion: lock the mouse on the form.
Code:Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Sub DisableTrap(CurForm As Form)
Dim erg As Long
'Declare a variable for the procedure
'to set the new coordinates
Dim NewRect As RECT
CurForm.Caption = "Mouse released"
'Set the new coordinates to full screen
With NewRect
.Left = 0&
.Top = 0&
.Right = Screen.Width / Screen.TwipsPerPixelX
.Bottom = Screen.Height / Screen.TwipsPerPixelY
End With
erg& = ClipCursor(NewRect)
End Sub
Public Sub EnableTrap(CurForm As Form)
Dim X As Long, Y As Long, erg As Long
'Declare a variable for the procedure
'to set the new coordinates
Dim NewRect As RECT
'Get the TwipsperPixel
'The Form's ScaleMode must be set to Twips!!!
X& = Screen.TwipsPerPixelX
Y& = Screen.TwipsPerPixelY
CurForm.Caption = "Mouse trapped"
'Set the Cursor-Region to the coordinates
'of the form
With NewRect
.Left = CurForm.Left / X&
.Top = CurForm.Top / Y&
.Right = .Left + CurForm.Width / X&
.Bottom = .Top + CurForm.Height / Y&
End With
erg& = ClipCursor(NewRect)
End Sub
Usage:
EnableTrap Me
DisableTrap Me
'Remember, put a DisableTrap Me in the Form_Unload event.