Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Howto retrieve desktop X and Y coordinates

Status
Not open for further replies.

mibosoft

Programmer
Jul 23, 2002
106
SE
Hi,
I use docked forms in VFP9. In order to keep non-docked dialogs frontmost, I have defined these as "desktop". On right click I want to position these dialogs next to the mouse pointer. How can I read the desktop X and Y coordinates?

(I have tried calculating it with help of mcols/mrow("",3) _screen.left/top etc. but without success)

Thanks,
Micael
 
I have tried calculating it with help of mcols/mrow("",3) _screen.left/top etc. but without success

What exactly goes wrong? I've just tried this from the Command Window:
Code:
ON KEY LABEL RIGHTMOUSE _screen.pset(mcol("",3), mrow("",3))
and I get a point on screen exactly under the tip of the mouse cursor each time that I right-click.

Geoff Franklin
 
The problem is that the dialog that I want to position is "Desktop". Its coordinates relates to the whole desktop area. If I have a "this.left=0" in the init event the dialog is positioned at the very left of the desktop regardless of where my VFP window is located.
 
The windows desktop as my desktop dialog seems to relate to it.
 
Hi,
Actually I found the solution myself at fox.wikis.com:

DECLARE SHORT GetCursorPos IN user32 STRING @ lpPoint

LOCAL lnX, lnY
= getMousePos (@lnX, @lnY) && gets cursor absolute position

PROCEDURE getMousePos (x, y)
LOCAL lcBuffer
lcBuffer = Repli(Chr(0), 8)
= GetCursorPos (@lcBuffer)
x = buf2dword(SUBSTR(lcBuffer, 1,4))
y = buf2dword(SUBSTR(lcBuffer, 5,4))

FUNCTION buf2dword (lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
Asc(SUBSTR(lcBuffer, 4,1)) * 16777216


Thanks anyway,
Micael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top