Use ClipCursor API function to keep the mouse pointer inside a form.
Use ClipCursor API function to keep the mouse pointer inside a form.
API Declarations
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Rate Use ClipCursor API function to keep the mouse pointer inside a form.
(2(2 Vote))
Dim lngX As Long
Dim lngY As Long
Dim lngReturn As Long
Dim NewRect As RECT
'Get the screens Twips per pixel (form's scalemode must be Twips)
lngX = Screen.TwipsPerPixelX
lngY = Screen.TwipsPerPixelY
'Set cursor region to that of form
With NewRect
.Left = Me.Left / lngX
.Top = Me.Top / lngY
.Right = .Left + Me.Width / lngX
.Bottom = .Top + Me.Height / lngY
End With
lngReturn = ClipCursor(NewRect)
Use ClipCursor API function to keep the mouse pointer inside a form. Comments
No comments yet — be the first to post one!
Post a Comment