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" _ (lpRect As Rect) As Long Private Declare Function ClipCursorBynum _ Lib "user32" _ Alias "ClipCursor" _ (ByVal lpRect As Long) As Long Private Sub Command1_Click() Dim dl As Long Dim myRect As Rect With myRect .left = ((Screen.Width - Width) \ 2) \ Screen.TwipsPerPixelX + 5 .top = ((Screen.Height - Height) \ 2) \ Screen.TwipsPerPixelY + 25 .right = ((Screen.Width + Width) \ 2) \ Screen.TwipsPerPixelX - 5 .bottom = ((Screen.Height + Height) \ 2) \ Screen.TwipsPerPixelY - 5 End With dl = ClipCursor(myRect) End Sub Private Sub Command2_Click() Dim dl As Long dl = ClipCursorBynum(0) End Sub Private Sub Form_Load() Caption = "Clip Cursor" Command1.Caption = "Lock" Command2.Caption = "Unlock" End Sub CTRL+ALT+DEL per sbloccare il cursore 1) put 2 command buttons on a form. 2) set StartUpPosition = "2 - CenterScr een" in Properties window. 3) copy the code below. 4) run the program. |