Option Explicit
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function ClipCursor Lib "User32.dll" (lpRect As Any) As Long ' retrieve the number of milliseconds that elapsed since Windows was started Private Declare Function GetTickCount Lib "kernel32.dll" () As Long Private mvarCurrentTick As Long ' for time measurement Public Sub DisableTrap(CurForm As Form) Dim NewRect As RECT With NewRect .Left = 0& .Top = 0& .Right = Screen.Width / Screen.TwipsPerPixelX .Bottom = Screen.Height / Screen.TwipsPerPixelY End With glRet = ClipCursor(NewRect) End Sub Public Sub EnableTrap(CurForm As Form) Dim X As Long, Y As Long Dim NewRect As RECT X = Screen.TwipsPerPixelX Y = Screen.TwipsPerPixelY With NewRect .Left = CurForm.Left / X .Top = CurForm.Top / Y .Right = .Left + CurForm.Width / X .Bottom = .Top + CurForm.Height / Y End With glRet = ClipCursor(NewRect) End Sub |