|
Post by Beaker on Mar 10, 2004 19:52:28 GMT
...by Halo 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
;Function MouseDown(button) ;Select button ; Case 1 Return GetAsyncKeyState(1) ; Case 2 Return GetAsyncKeyState(2) ; Case 3 Return GetAsyncKeyState(4) ; End Select ;End Function
Slight variation (thanks to JimB): ;.lib "user32.dll" ;api_GetCursorPos% (lpPoint*) : "GetCursorPos" ;api_ClientToScreen% (hWnd%,lpPoint*) : "ClientToScreen"
Type POINTTYPE Field x%,y% End Type Global point.POINTTYPE=New POINTTYPE
Function MouseOverGadget(gad)
point\x=0 : point\y=0 api_ClientToScreen(QueryObject(gad,1),point) Local gadX%=point\x , gadY%=point\y api_GetCursorPos(point) Local mX%=point\x , mY%=point\y If mX>=gadX And mX<gadX+GadgetWidth(gad) If mY>=gadY And mY<gadY+GadgetHeight(gad) Return True EndIf EndIf
End Function More here: www.blitzbasic.com/codearcs/codearcs.php?code=1290www.blitzbasic.com/Community/posts.php?topic=43826
|
|