Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Obtain object position relative to full screen
Message
From
05/10/2008 18:31:20
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01352776
Message ID:
01352883
Views:
23
>>How do you obtain the position of an object in relation to the full screen? OBJTOCLIENT( ) returns a position or dimension of a control or object relative to its form, and perhaps you can go up the chain of parents all the way to the full screen?
>
>Take a look at Pixels and Foxels for some pointers.

Apparent solution, FWIW:

The overall objective is to determine the position of the mouse cursor, in pixels, relative to the top/left of a browser object.

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.
MouseY_RelativeToWindow = Calculated by Cetin's method
MouseX_RelativeToWindow = Calculated by Cetin's method

loBrowser	  = Thisform.pgfMain.page5.oMapcontainer.oBrowser
lnBrowserTop  = _SCREEN.Top  + Thisform.Top  + OBJTOCLIENT(loBrowser,1) + SYSMETRIC(9) + 4
lnBrowserLeft = _SCREEN.Left + Thisform.Left + OBJTOCLIENT(loBrowser,2) + SYSMETRIC(10) + 4

MouseY_RelativeToBrowserObject = MouseY_RelativeToWindow - lnBrowserTop
MouseX_RelativeToBrowserObject = MouseX_RelativeToWindow - lnBrowserLeft
Addition: Seems I will need to add a new fudge factor because the item shown has its own offset, but that is another matter.

Alex
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform