MouseTrap




'API Declare


Public Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Public lTwipsX As Long
Public lTwipsY As Long
Public RectArea As RECT

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

Public Function TrapCursor(frm As Form)
lTwipsX=Screen.TwipsPerPixelX
lTwipsY=Screen.TwipsPerPixelY

With RectArea
.Left=frm.Left/lTwipsX
.top=frm.Top/lTwipsY
.right=.Left+frm.Width/lTwipsX
.bottom=.top+frm.height/lTwipsY
End With
call ClipCursor(RectArea)
End Function

Public Function ReleaseCursor(frm As Form)
lTwipsX=Screen.TwipsPerPixelX
lTwipsY=Screen.TwipsPerPixelY

With RectArea
.left=0
.top=0
.right=screen.width/lTwipsX
.bottom=screen.height/lTwipsY
End With
call ClipCursor(RectArea)
End Function












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