how can i make it so that the mouse cursor stays WITHIN a form, until that form is unloaded by clicking something withing that form?
Printable View
how can i make it so that the mouse cursor stays WITHIN a form, until that form is unloaded by clicking something withing that form?
try this tip:
http://www.vb-world.net/tips/tip78.html
thanks dude
appreciated
Try this: Needs 2 CommandButtons
Code:Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim W_RECT As RECT
Private Sub Command1_Click()
'Trap the cursor
GetWindowRect Me.hwnd, W_RECT
ClipCursor W_RECT
End Sub
Private Sub Command2_Click()
'Untrap the cursor
GetWindowRect GetDesktopWindow, W_RECT
ClipCursor W_RECT
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call Command2_Click
End Sub