[bmx] Mouse commands by JoshK [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:39

Previous topic - Next topic

BlitzBot

Title : Mouse commands
Author : JoshK
Posted : 1+ years ago

Description : Replacement mouse commands for gadget mouse coordinates.

Code :
Code (blitzmax) Select
SuperStrict

Import maxgui.maxgui
Import pub.win32

Private

?win32
Extern "win32"
Function GetCursorPos:Int(point:Byte Ptr)
Function SetCursorPos:Int(x:Int,y:Int)
Function ScreenToClient:Int(hwnd:Int,point:Byte Ptr)
EndExtern
?

Public

Function MouseX:Int(gadget:TGadget=Null)
Local hwnd:Int
Local pos:Int[2]
GetCursorPos pos
If gadget screentoclient QueryGadget(gadget,QUERY_HWND),pos
Return pos[0]
EndFunction

Function MouseY:Int(gadget:TGadget=Null)
Local hwnd:Int
Local pos:Int[2]
GetCursorPos pos
If gadget screentoclient QueryGadget(gadget,QUERY_HWND),pos
Return pos[1]
EndFunction

Function MoveMouse(x:Int,y:Int,gadget:TGadget=Null)
Local hwnd:Int
Local pos:Int[2]
pos[0]=x
pos[1]=y
If gadget clienttoscreen QueryGadget(gadget,QUERY_HWND),pos
SetCursorPos pos[0],pos[1]
EndFunction


Comments : none...