Lazze,
Try this. It needs a couple of userlibs adding before you run it...
The function in the example can be used to test if the mouse is over *any* Blitz gadget.
; MouseOverGadget() - example
; USERLIBS ---------------------------------------
; .lib "user32.dll"
; api_GetCursorPos% (lpPoint*) : "GetCursorPos"
; api_ClientToScreen% (hWnd%,lpPoint*) : "ClientToScreen"
; ------------------------------------------------
; required by both api_ calls
Type POINTTYPE
Field x%,y%
End Type
Global point.POINTTYPE=New POINTTYPE
; GUI
win=CreateWindow("Mouse/Canvas Test",160,120,340,300,Desktop(),1)
can=CreateCanvas(20,30,250,100,win)
bt=CreateButton("button",60,150,70,22,win)
sl=CreateSlider(60,190,240,24,win)
SetBuffer CanvasBuffer(can)
; LOOP
Repeat
Select WaitEvent(1)
Case $803 : Exit ; window [X]
Case $103 : If EventData()=27 Exit ; key [ESC]
Default
Cls
Text 10,10,"Mouse over canvas = "+MouseOverGadget(can)
Text 10,30,"Mouse over button = "+MouseOverGadget(bt)
Text 10,50,"Mouse over slider = "+MouseOverGadget(sl)
FlipCanvas can
End Select
Forever
End
; return TRUE if mouse is over a gadget
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