473,327 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 27539
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Susan Bricker | last post by:
Greetings. I am trying to position opened forms so that they are cascaded on the screen. I have discovered the movesize action (for the DoCmd) and Move property of a form (for Acc 2002/2003). ...
1
by: JJ | last post by:
Hi, I am buidling some controls dynamically in the .cs file, context menu. I am wondering if there is any chance I could obtain the location of any controls and set the location of another...
1
by: xx75vulcan | last post by:
Howdy! I need to find a way to remove the absolute positioning on a JavaScript Menu that was given to me. If I remove the values "162" and "255" in the line: var pMenu = new...
0
by: webmaster | last post by:
I've been playing around with asp.net 2.0/vs.net 2005/C# 2005 - I had a few noob questions. 1. Is there a setting that sets all current and future controls on a page to position absolutely...
5
by: Martin Larsen | last post by:
Hi, I have a script for a CMS that preloads an image by setting the SRC attribute. The problem is that the location of the image as seens from the final HTML page depends on whether the CMS has...
1
by: canteloup | last post by:
Hi, I need to find a way to determinate where a control is on a windows form or panel control. I have a panel contro setted with autoscroll = true and when I move a control contained by it, I need to...
0
by: canteloup | last post by:
Hi, I need to find a way to determinate where a control is on a windows form or panel control. I have a panel contro setted with autoscroll = true and when I move a control contained by it, I need to...
1
by: Miro | last post by:
In my book the book drags a datagridview and a detailsdatagrid onto the form, The person is able to set the two grids side by side. In mine - i can only seem to set them under eachother. ...
0
by: thesti | last post by:
hello, i'm using ms access as the database for crystal report. when setting the connection in crystal report, it takes the absolute location of the *.mdb file, (C:\myProgram\database\.mdb) so,...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.