Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi

i need to get x,y of label in access form when moving on label at the the top corner of it in access form it gives us 96,76 (mousemove event and using GetCursorPos pt : text2=pt.x & "..." & pt.y

but when use (me.label1.left-me.windowleft)/15 it gives us 76.8

how kind of Api function we have to use to get x=95 like getcursorpos

What I have tried:

(me.label1.left-me.windowleft)/15 different from pt.x
also tried :
ClientToScreen Me.hwnd,pt
pt.x=(Me.label1.left-Me.WindowLeft)
text2=pt.x/15 ... give me 91.8 so far from 96


me.windowleft(Access document)

Returns an Integer indicating the screen position in twips of the left edge of a form relative to the left edge of the Microsoft Access window. Read-only.
Posted
Updated 26-Jan-22 22:39pm
v3
Comments
Dave Kreskowiak 23-Jan-22 11:31am    
This is a repost of https://www.codeproject.com/Questions/5323231/Return-control-pos-in-screen.

Don't post the same question over and over again. If you've got something to add to the original question, hover the mouse over your question and a "Improve question" link will show up. Click that and edit your question to add the new details.
[no name] 23-Jan-22 12:17pm    
this is not same i think nobody can give right answer to this post
Dave Kreskowiak 23-Jan-22 12:33pm    
I won't because I don't work with Access at all.

Most people here don't/won't work with Access.
[no name] 27-Jan-22 10:27am    
Finally They Can offer some way one by one and guide me, which Api Function to be used in turn

1 solution

GetCursorPos returns the position of the cursor relative to the screen and gives values in Pixels

Me.label1.Left returns the position of the label relative to the form and gives values in twips

To complicate matters even further Window.Left is going to be relative to the Access Application itself. You will need to get a handle to the application window then use something like GetWindowRect to find it's position. There is an archived example of similar here - Q242308: HOWTO: Find a Window Handle from an Instance Handle | KnowledgeBase Archive[^]

Get the pixel positions of everything and you can then calculate the position of the label relative to the form relative to the application then relative to the screen. Edit - you may need to take into account label/form margins and padding

It might be simpler than that - perhaps you just want to convert Twips to Pixels? In which case see Convert Twip to Pixel (X)[^]
 
Share this answer
 
v2
Comments
[no name] 27-Jan-22 10:26am    
Label1.Left = 0.8"
The Left in screen is 96 Not 76.8
(0.8×1,440)×(96÷1,440)=76.8
How can get the 96 ( Correct Point )
you mean get the handle of MDICHILDREN First And Change to point the use (mHandle.Left-me.label1.left)?
CHill60 27-Jan-22 11:59am    
What is MDICHILDREN?
[no name] 27-Jan-22 10:31am    
i have to use GetWindowRect Of Access App Or MDIClient Window?

Why ask , because i want to create Static On The Label Coordinate

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900