Userlibs! This works here...
; -----------------------------------------------------------------------------
; IMPORTANT: Add these to user32.decls in your Userlibs folder:
; -----------------------------------------------------------------------------
; .lib "user32.dll"
; -----------------------------------------------------------------------------
; GetCursorPos% (point*): GetCursorPos
; ScreenToClient% (window, point*): ScreenToClient
; GetActiveWindow% (): GetActiveWindow
; SetWindowPos% (window, order, x, y, width, height, flags): SetWindowPos
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; Required constants for UnstickWindow ()
; -----------------------------------------------------------------------------
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = 1
Const SWP_NOMOVE = 2
; -----------------------------------------------------------------------------
; Required structure for MouseInWindow ()
; -----------------------------------------------------------------------------
Type MousePoint
Field x
Field y
End Type
; -----------------------------------------------------------------------------
; Functions
; -----------------------------------------------------------------------------
Function MouseInWindow (mp.MousePoint)
GetCursorPos (mp)
ScreenToClient (GetActiveWindow (), mp)
If (mp\x < 0) Or (mp\x > GraphicsWidth ()) Or (mp\y < 0) Or (mp\y > GraphicsHeight ())
Return 0
EndIf
Return 1
End Function
Function UnstickWindow ()
SetWindowPos (GetActiveWindow (), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
End Function
; -----------------------------------------------------------------------------
; Demo...
; -----------------------------------------------------------------------------
AppTitle "Move mouse outside window..."
Graphics3D 640, 480
; -----------------------------------------------------------------------------
; Important! Create a 'MousePoint' and pass to MouseInWindow () below...
; -----------------------------------------------------------------------------
mp.MousePoint = New MousePoint
Repeat
Cls
; SPACE = switch between full screen and windowed...
If KeyHit (57)
; Mode switch variable...
mode = 1 - mode
; Close graphics mode...
EndGraphics
; If going into windowed mode, unstick window!
If mode = 1
Graphics3D 640, 480, 0, 2
UnstickWindow ()
Else
Graphics3D 640, 480
EndIf
EndIf
Text 20, 20, "Hit SPACE to switch modes..."
; Check in mouse is within window...
If MouseInWindow (mp) = False
Text 20, 40, "Outside window!"
EndIf
Flip
Until KeyHit (1)
End