I put these in CShop, and they worked without a hitch. These mouse commands will work relative to any gadget, so you can use panels for OpenGL viewports instead of canvases that flip and cover the rendering.
Function MouseX(gadget=0)
If Not gadget gadget=Desktop()
hwnd=QueryObject(gadget,1)
buffer=CreateBank (8)
api_GetCursorPos (buffer)
api_ScreenToClient (hwnd, buffer)
x=PeekInt(buffer,0)
FreeBank buffer
Return x
End Function
Function MouseY(gadget=0)
If Not gadget gadget=Desktop()
hwnd=QueryObject(gadget,1)
buffer=CreateBank(8)
api_GetCursorPos(buffer)
api_ScreenToClient(hwnd, buffer)
y=PeekInt(buffer,4)
FreeBank buffer
Return y
End Function
Function MoveMouse(x,y,gadget=0)
If Not gadget gadget=Desktop()
hwnd=QueryObject(gadget,1)
buffer=CreateBank(8)
PokeInt buffer,0,x
PokeInt buffer,4,y
api_ClientToScreen(hwnd,buffer)
x=PeekInt(buffer,0)
y=PeekInt(buffer,4)
api_SetCursorPos(x,y)
FreeBank buffer
End Function
|