469,312 Members | 2,493 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

Absolute location of control

Is there a way to get a controls location in screen coordinates? (not
relative to the container it is in)?

Thanks,
Jon
Oct 24 '06 #1
5 26466
System.Windows.Forms.Control

has a function called PointToScreen(Point p), not sure whether this is
what your look for..

Jon Slaughter wrote:
Is there a way to get a controls location in screen coordinates? (not
relative to the container it is in)?

Thanks,
Jon

Oct 24 '06 #2
n!
Is there a way to get a controls location in screen coordinates? (not
relative to the container it is in)?
You can use the System.Windows.Forms.Control.PointToScreen method to convert
from client coordinates to screen coordniates and the
System.Windows.Forms.Control.PointToClient to convert from screen
coordinates to client coordinates.

n!
Oct 24 '06 #3

Is there an easy way to work with a controls location relative to the
form that it is in instead of the container? I need to do some
calculations based on where the control in the form but I can only seem
to find properties that give the controls location w.r.t. its container
which will through off all my calculations ;/

(right now I see the only way to do is is first convert everything to
screen coordinates then from there to form coordinates ;/)

Thanks,
Jon

Oct 24 '06 #4
This can be done by using the System.Windows.Forms.Control.PointToScreen
(http://msdn2.microsoft.com/en-us/lib...ttoscreen.aspx)
method to get the absolute screen coordinate of the point relative to the
Control, and then using the System.Windows.Forms.Control.PointToClient
method
(http://msdn2.microsoft.com/en-us/lib...ttoclient.aspx)
from the Form to get the screen coordinate of the point relative to the
Form.

--
HTH,

Kevin Spencer
Microsoft MVP
Short Order Coder
http://unclechutney.blogspot.com

What You Seek Is What You Get

<Jo***********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>
Is there an easy way to work with a controls location relative to the
form that it is in instead of the container? I need to do some
calculations based on where the control in the form but I can only seem
to find properties that give the controls location w.r.t. its container
which will through off all my calculations ;/

(right now I see the only way to do is is first convert everything to
screen coordinates then from there to form coordinates ;/)

Thanks,
Jon

Oct 25 '06 #5

"Kevin Spencer" <sp**@uce.govwrote in message
news:e$**************@TK2MSFTNGP02.phx.gbl...
This can be done by using the System.Windows.Forms.Control.PointToScreen
(http://msdn2.microsoft.com/en-us/lib...ttoscreen.aspx)
method to get the absolute screen coordinate of the point relative to the
Control, and then using the System.Windows.Forms.Control.PointToClient
method
(http://msdn2.microsoft.com/en-us/lib...ttoclient.aspx)
from the Form to get the screen coordinate of the point relative to the
Form.
duh ;) Shows how much I'm really thinking ;/

Thanks,
Jon
Oct 25 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by JJ | last post: by
1 post views Thread by xx75vulcan | last post: by
5 posts views Thread by Martin Larsen | last post: by
1 post views Thread by canteloup | last post: by
1 post views Thread by Miro | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.