include("../include.php"); writeHeader("Restrict cursor to a form/control", "Programming » Visual Basic 6 » Visual Basic 6 Code » Mouse » ");?>
Private Declare Function ClipCursor Lib "user32" (ByVal lpRect As Long) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _ lpRect As RECT) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Public Sub ClipCursorToForm(F As Form) Dim R As RECT GetWindowRect F.hwnd, R ClipCursor VarPtr(R) End Sub Public Sub ClipCursorToControl(C As Control) Dim R As RECT GetWindowRect C.hwnd, R ClipCursor VarPtr(R) End Sub Public Sub UnClipCursor() ClipCursor 0 End Sub