473,320 Members | 1,863 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,320 software developers and data experts.

relative position in different resolutions

How can i get relative position in different resolutions using c# ??
Jan 31 '09 #1
9 12414
vekipeki
229 Expert 100+
You can read this link for automatic scaling: http://msdn.microsoft.com/en-us/libr...05(VS.80).aspx.

If you want to have your controls positioned and resized dynamically as you resize the parent form, then it is a different thing, because that is not related to the screen resolution, but rather the size of the parent form.

In that case you should use layout panels, and anchor your controls to their container panels. You can achieve relative positioning using FlowLayoutPanel or TableLayoutPanel. Also, by using any control's Anchor property, you can anchor control's sides (top/bottom/left/right) to a parent control, to make it resize together with the parent control.

Check this link for an example of using the TableLayoutPanel: http://msdn.microsoft.com/en-us/library/991eahec.aspx
Jan 31 '09 #2
Thanks for your advice , but i need to Know how to get relative position in different resolutions using c# ? Do you have any idea ??
Feb 1 '09 #3
vekipeki
229 Expert 100+
If you want to get the screen resolution programmatically, you can use:

Expand|Select|Wrap|Line Numbers
  1. System.Drawing.Rectangle resolution = Screen.GetWorkingArea(someForm);
where 'someForm' is a form that is located on the display you are interested in (don't forget the possibility of multiple displays).

But it would help if you would describe in detail what you are trying to accomplish.
Feb 2 '09 #4
This is the problem

I have Form display in Full Screen Mode; I used Scale Method built in .Net to Scale all controls in the form at the Form Load

SizeF MaximizeScalFactor = new SizeF((float) Screen.PrimaryScreen.Bounds.Width / 800, (float) Screen.PrimaryScreen.Bounds.Height / 600);
button1.Scale(MaximizeScalFactor);
All controls used at form (button ,richtextbox,listbox,label) was Scale correctly expect FlashControl it was Scale but it's position changed . So I try to calculate all relative position depend on the screen resolution.
Feb 2 '09 #5
What about PointToScreen & PointToClient??? Is it useful in case of getting relative position in different resolutions?
Feb 3 '09 #6
vekipeki
229 Expert 100+
No, they are not related to screen resolution. They simply convert point coordinates between your client control and screen (by translating them).

For example, if you have a panel inside a form, and then a text box inside that panel, text box location will be relative to the top-left point of the parent panel ("client coordinates"). Panel location will be relative to the top-left origin of the parent form. Using PointToScreen you would be able to convert all those points into a single coordinate system (relative to the screen top-left corner).
Feb 3 '09 #7
OK, but this code not gives me relation position? Its only get screen resolution.
1. System.Drawing.Rectangle resolution = Screen.GetWorkingArea(someForm);
If I have point (479, 9) at screen resolution 1024,786
IS this Equation true to get this point at another resolution?
(472*Newresoluation.x, 9* Newresoluation.y) or NO??
Feb 3 '09 #8
vekipeki
229 Expert 100+
So, if your x coordinate is 400px in 800x600 resolution, and you want it to be 512px in 1024x768 resolution, then the way to get the new coordinate is obviously:

a) 400px / 800px = 1/2
b) 1/2 * 1024px = 512px

So, first divide with the old resolution, and then multiply with new resolution.
Feb 3 '09 #9
and applay this to Y coordinate also to have point in new resoluation .

i mean the answer of my question
How can i get relative position in different resolutions using c# ??


By this equation :

a) Old point.x / OldResoluation.x = R

b) R * newResoluation.x = relativeXposition

and so on for Y .


if Yes , Thanx aloooot :)
Feb 3 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Nige | last post by:
I've just given one of my sites (www.wealdbroadband.co.uk) an overhaul. Anyone know if there is a way of fixing text at a certain relative position down a page? I'd like the "(c) 2003 ..." notice...
4
by: boclair | last post by:
Is this a known problem with IE6? I have a provisional two column layout, the left menu column is positioned absolute. The contents column is positioned relative. The contents column has an...
1
by: Luqman | last post by:
Where is Form Relative Position and Absolute Position in VS.Net 2005 ? Best Regards, Luqman
8
by: Edward | last post by:
I used to do this all the time in HTML-table layouting. How do I do this in CSS? -------------------------------------------------- <table width="400px"> <tr> <td bgcolor="beige">one line of...
1
by: jobs | last post by:
I'm trying to understand this and don't get it... I found some code that looks like it's going to work if I can make sense of how to position the div. The code displays a div with some data...
11
by: Neil | last post by:
Does anyone know of an add-on or other that can be implemented into an MDB front end to allow its forms and reports to look the same at different screen resolutions?
1
by: dmorand | last post by:
I'm trying to get my site to look somewhat decent across different resolutions. Should I change all of my fonts to use em's rather than px? Is that a good solution to fix my resolution issues?
0
by: Rain | last post by:
In the example below. If I have the position:relative in the first div, then the menu disapears when dropped, if I do not have it, then it apears over the top of all the other divs when dropped. ...
5
Frinavale
by: Frinavale | last post by:
Hi! I'm attempting to display a <div> element on top of my page's content so that the user cannot interact with it while being prompted to answer a question. I have set this <div> to have a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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: 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

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.