Hi Alex,
>With the help of an answer by Cetin ( Message #
576288 ) we can determine the position of the mouse in pixels relative to the top left of the screen, so the task becomes calculating the position of the top-left of the browser object relative to the screen. Then we can calculate the desired offsets.
>
>The original calculations didn't quite jibe with what I saw, so I fudged the top and left by 4 as shown below and then it seems to work. Don't know the justification of the fours, but maybe not by concidence _VFP.Top and _VFP.Left are -4 when the window is maximized.
>
The 4 is probabaly related to SYSMETRIC(3) and SYSMETRIC(4) (Width and height of sizable window frame). Using this technique you would still need to check ThisForm.BorderStyle, ThisForm.TitleBar and ThisForm.HalfHeightCaption before adding the SYSMETRICs.
However, you may be better off using the ClientToScreen API function. You are using the GetCursorPos which returns the coordinates relative to the screen. The ClientToScreen returns your window client coordinates relative to the screen.
DECLARE long GetCursorPos IN WIN32API String@
DECLARE long ClientToScreen IN WIN32API Long, String@
lqPointMouse = 0h0000000000000000
lqPointClient = 0h0000000000000000
GetCursorPos(@lqPointMouse)
ClientToScreen(ThisForm.HWnd, @lqPointClient)
lnLeftMouse = CTOBIN(SUBSTR(lqPointMouse,1,4),"4rs")
lnTopMouse = CTOBIN(SUBSTR(lqPointMouse,5,4),"4rs")
lnLeftClient = CTOBIN(SUBSTR(lqPointClient,1,4),"4rs")
lnTopClient = CTOBIN(SUBSTR(lqPointClient,5,4),"4rs")
lnLeftBrowser = (lnLeftMouse-lnLeftClient) - OBJTOCLIENT(ThisForm.oBrowser,2)
lnTopBrowser = (lnTopMouse-lnTopClient) - OBJTOCLIENT(ThisForm.oBrowser,1)
IF lnLeftBrowser < 0 OR lnLeftBrowser > ThisForm.oBrowser.Width
lnLeftBrowser = -1
lnTopBrowser = -1
ENDIF
IF lnTopBrowser < 0 OR lnTopBrowser > ThisForm.oBrowser.Height
lnTopBrowser = -1
lnLeftBrowser = -1
ENDIF
WAIT WINDOW NOWAIT NOCLEAR ;
"x: "+TRANSFORM(lnLeftBrowser);
+" y: "+TRANSFORM(lnTopBrowser)