473,706 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 27611
System.Windows. Forms.Control

has a function called PointToScreen(P oint 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.P ointToScreen method to convert
from client coordinates to screen coordniates and the
System.Windows. Forms.Control.P ointToClient 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.P ointToScreen
(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.P ointToClient
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.goo glegroups.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.govwr ote in message
news:e$******** ******@TK2MSFTN GP02.phx.gbl...
This can be done by using the System.Windows. Forms.Control.P ointToScreen
(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.P ointToClient
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
1979
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). However, if the application is opened up on different monitors (e.g.; 17" or 19"), the relative location of the opened form is not the same (i.e.; on the bigger monitor the opened form is too far over to the right and too high). What I want to...
1
2312
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 control to that location. i.e. just setting and getting the location. Concern: 1.When is the best time to get the location? After PageLoad? CreateChildControls?
1
1211
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 PopupMenu('pMenu'); with (pMenu) {
0
1297
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 automatically so that I don't have to set this sytle every time? 2. I'd like to code have a "New" button, that when selected makes visible a detailview in insert mode and with only the insert command available. I would imagine I'd be adding an...
5
5189
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 search engine friendly (SEF) url's urned on. If it is not on, the location is just the normal absolute location of the image, and it is then easy to fetch it.
1
2909
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 know where the control really is on the panel. So what the location show me is the position on the part of panel show in screen, it means that if I scroll the panel, the position of that control change. Could some one help me?
0
1414
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 know where the control really is on the panel. So what the location show me is the position on the part of panel show in screen, it means that if I scroll the panel, the position of that control change. It's an c# app. Could some one help me?
1
1340
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. Its almost like I am missing something like an 'absolute location' parameter or something like frontpage had to drag items on the form.
0
904
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, when i copy the program to another computer, the crystal report won't work because the .mdb file is located on different location. how to solve this problem? Thank you,
1
9055
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7911
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5939
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4709
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2502
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.