Rafael,
To capture the mouse you use SetCapture():
The SetCapture function sets the mouse capture to the specified window belonging to the current thread. Once a window has captured the mouse, all mouse input is directed to that window, regardless of whether the cursor is within the borders of that window. Only one window at a time can capture the mouse.
You may do:
- Code: Select all Expand view RUN
oWnd:Capture()
oWnd:bLClicked := {|r,c| MsgInfo("Clicked at "+STR(x)+STR(y)}
oWnd is your window. Not the desktop window.
From that moment on, any click, anywhere on the screen, will be routed to your oWnd:bLClicked codeblock. Same for bLButtonUp, bMButtonDown, bMButtonUp, bRClicked, bRButtonUp, bLDblClick.
To release the capture, you call ReleaseCapture() (no parameters).
The coordinates you will get are relative to the window that has captured the mouse, so if you want to locate another window from a click then you have to use WindowFromPoint( nRow, nCol ) --> hWnd. To locate a specific child control use ChildWindowFromPoint( hWndParent, aPoint ) where aPoint is { nRow, nCol }.