RestrMouseHideCur




'You can use the ClipCursor And ShowCursor APIs, ie.


Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

Private Sub Command1_Click()
Static bRestricted As Boolean
Dim tRECT As RECT

bRestricted = Not bRestricted
If bRestricted Then
'Restrict the Cursor to Inside the Form Area

Call GetWindowRect(hwnd, tRECT)
Call ClipCursor(tRECT)
Else
'Release the Cursor

Call ClipCursor(ByVal 0&)
End If
End Sub

Private Sub Command2_Click()
Static bHide As Boolean
bHide = Not bHide
Call ShowCursor(Abs(Not bHide))
End Sub










( restrmousehidecur.html )- by Paolo Puglisi - Modifica del 17/12/2023