Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the X,Y position of a TWinControl (relative to the screen)

I'm trying to show a custom hint in a TWinControl but I can't figure out how to get it's position.

Using position 0,0 shows the hint on the top of my screen (outside the window) so I guess it must be the position of the control on the screen.

Edit:

I've found the TControl Property ClientOrigin which returns what I've expected, is it correct to use ClientOrigin.X and ClientOrigin.Y?

like image 331
Fabio Gomes Avatar asked Nov 14 '08 12:11

Fabio Gomes


1 Answers

TControl.ClientToScreen gives you the screen coordinates for a given point within the control.

lPoint := Panel1.ClientToScreen(Point(0,0));
Label1.Caption := Format('Screen: %d, %d', [lPoint.X, lPoint.Y]);
like image 146
Bruce McGee Avatar answered Nov 03 '22 07:11

Bruce McGee