08-18-2023, 12:17 PM
And there's always THIS option, if you just don't want to be worried about it at all:
Code: (Select All)
Type Rectangle
left As Long
top As Long
right As Long
bottom As Long
End Type
Dim Rec As Rectangle
Declare Dynamic Library "User32"
Function ClipCursor%% (Rect As Rectangle) 'sets mouse box work area on desktop
Sub SetCursorPos (ByVal x As Long, Byval y As Long) 'move cursor position
End Declare
Screen _NewImage(720, 480, 32)
sx = 100: sy = 100
ScreenMove sx, sy
SetCursorPos sx + 10, sy + 10
Rec.left = sx
Rec.top = sy
Rec.bottom = sy + 480
Rec.right = sx + 720
work%% = ClipCursor(Rec)
Print "Click the mouse to quit!"
Do
While _MouseInput: Wend
_Limit 15
Loop Until _MouseButton(2) Or _MouseButton(1)
System
Sub ScreenMove_Middle
$If BORDERDEC = UNDEFINED Then
$Let BORDERDEC = TRUE
Declare Library
Function glutGet& (ByVal what&)
End Declare
$End If
BorderWidth = glutGet(506)
TitleBarHeight = glutGet(507)
_ScreenMove (_DesktopWidth - _Width - BorderWidth) / 2 + 1, (_DesktopHeight - _Height - BorderWidth) / 2 - TitleBarHeight + 1
End Sub
Sub ScreenMove (x, y)
$If BORDERDEC = UNDEFINED Then
$LET BORDERDEC = TRUE
DECLARE LIBRARY
FUNCTION glutGet& (BYVAL what&)
END DECLARE
$End If
BorderWidth = glutGet(506)
TitleBarHeight = glutGet(507)
_ScreenMove x - BorderWidth, y - BorderWidth - TitleBarHeight
End Sub