I came up with this solution, using the User32 API function; ClipCursor.
#constant USER32 1
type t_point
x as integer
y as integer
endtype
type t_rect
left as integer
top as integer
right as integer
bottom as integer
endtype
dim upperleft(0) as t_point
dim client(0) as t_rect
load dll "user32.dll", USER32
hWnd = call dll(USER32, "GetActiveWindow")
call dll USER32, "GetClientRect", hWnd, client()
upperleft(0).x = client(0).left
upperleft(0).y = client(0).top
call dll USER32, "ClientToScreen", hWnd, upperleft()
call dll USER32, "OffsetRect", client(), upperleft(0).x, upperleft(0).y
call dll USER32, "ClipCursor", client()
wait key
call dll USER32, "ClipCursor", 0
delete dll USER32
Typed this in on a iPhone, so I hope there are no errors.