473,594 Members | 2,768 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 27601
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
1972
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
2307
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
1210
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
1291
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
5186
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
2907
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
1410
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
1334
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
902
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,
0
7936
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7874
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8241
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8227
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
6646
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
5738
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
5402
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
3853
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...
1
1469
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.