473,407 Members | 2,306 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,407 software developers and data experts.

How to make my application resolution aware?

I am writing a Form application
I need it to fit both resolution of 1600*1200 and 800*600
(and any other resolution that might jump in)
the application is meant for regular PCs

another question is what the difference between the Dock and Anchor
properties?

i tried to use them (mutual exclusive of course) but with no success

my application doesnt respond correctly even if i just resize it !!

please i need this help quickly

thanks

Jul 11 '06 #1
7 3302
aviad wrote:
I am writing a Form application
I need it to fit both resolution of 1600*1200 and 800*600
(and any other resolution that might jump in)
the application is meant for regular PCs

another question is what the difference between the Dock and Anchor
properties?
The Dock property will expand the control to fill the specified dock area.
The anchor property will just anchor the control to the specified location.
i tried to use them (mutual exclusive of course) but with no success

my application doesnt respond correctly even if i just resize it !!

please i need this help quickly

thanks
You will need to decide what behaviour you want for your application
when you resize.
Do you want the fonts to change depending on the resolution?
Do you just want the control sizes to change as you resize the
form/resolution?

You have to do it manually using the dock and anchor properties.

You can also look at sizers/splitters.

JB
Jul 12 '06 #2

aviad wrote:
I am writing a Form application
I need it to fit both resolution of 1600*1200 and 800*600
(and any other resolution that might jump in)
the application is meant for regular PCs

another question is what the difference between the Dock and Anchor
properties?
Anchor maintains a constant distance between the anchored side(s) of
the control and the corresponding side(s) of the container. So, if you
place a TextBox directly on a Form, and Anchor the TextBox
Left,Top,Right, then as you resize the Form the TextBox will stay a
constant distance from the top of the form, but get wider or narrower
depending upon the size of the form.

Dock does one of five different things, depending upon its setting.

Dock Left means that the control will always be pressed against the
left edge of the container. As the container gets bigger or smaller,
the control will maintain a constant width but will always get taller
or shorter to fill the entire height of the container.

For example, if you have a ListView and set it to Dock Left, it will
always have the same width, and will always be against the left edge of
the Form, but will get taller or shorter to always fill the Form
vertically.

Dock Right means the same thing but the control will always be pressed
against the right edge of the container.

Dock Top means that the control will always be pressed against the top
of the container. The control will maintain a constant height, but will
grow or shrink its width to always take up the full width of the
container.

Dock Bottom means the same thinge but the control will always be
pressed against the bottom edge of the container.

Dock Fill means that the control will fill the entire container.

If there are several docked controls in one container, they are docked
back to front (in "Z order"): the first control docks to the edge of
the container, the second (in back-to-front order) docks into the space
left in the container after the first control docks, etc.

Now, here's the trick to it: use Panels. The secret (in VS2003, at
least) to making nicely resizing applications is to put your controls
within Panels and then dock the panels.

For example, I have a classic "maintenance screen" form: buttons along
the bottom (including OK and Cancel), ListView on the left with all of
the items that can be maintained, and textboxes and comboboxes on the
right that when you click on an item in the list view, it populates the
controls on the right with properties that the user can change.

What I want is that the buttons always stay along the bottom. As the
form is made taller, the ListView gets taller, but blank space opens up
on the right bottom, because the textboxes, etc, don't grow. As the
form is made wider, the additional width is given to the ListView,
because the controls on the right don't benefit from additional width.
This is how to set it up (in VS2003, .NET 1.1):

Add a Panel to the form, call it buttonPanel. Dock it Bottom and make
it high enough to hold the buttons. Put the buttons in here. The
buttons can have the default Dock and Anchor settings.

Add another panel to the form, call it detailsPanel. Dock it Right and
make it wide enough to hold the text boxes / combo boxes for the item
details. Put the text boxes and combo boxes in here.

Add the ListView to the form. Dock it Fill. It should fill the space up
to the edges of the buttonPanel and the detailsPanel.

Now, as you resize the form, you should see the ListView growing and
shrinking to take up the space.

Now, in VS2005 (.NET 2.0) there is something called LayoutManagers that
allow you to do nicer stuff / use fewer panels-within-panels, but the
same tricks still work in .NET 2.0: decide how you want your Form to
act when it's resized, block it out using docked Panels, then place
controls on the panels.

Oh, and it's nice to your user to use a Splitter (in VS2003) / a
SplitContainer (in VS2005) to allow your user to resize the areas you
allocate to various controls. Get the docking / anchoring working
first, though, so that you understand it... then play with splitters.

You can also try reading this, which I just found:

http://msdn.microsoft.com/library/de...NETVBdev05.asp

Jul 12 '06 #3
Thanks very much to both of you John and Bruce
i think i got the principle now
Bruce Wood wrote:
aviad wrote:
I am writing a Form application
I need it to fit both resolution of 1600*1200 and 800*600
(and any other resolution that might jump in)
the application is meant for regular PCs

another question is what the difference between the Dock and Anchor
properties?

Anchor maintains a constant distance between the anchored side(s) of
the control and the corresponding side(s) of the container. So, if you
place a TextBox directly on a Form, and Anchor the TextBox
Left,Top,Right, then as you resize the Form the TextBox will stay a
constant distance from the top of the form, but get wider or narrower
depending upon the size of the form.

Dock does one of five different things, depending upon its setting.

Dock Left means that the control will always be pressed against the
left edge of the container. As the container gets bigger or smaller,
the control will maintain a constant width but will always get taller
or shorter to fill the entire height of the container.

For example, if you have a ListView and set it to Dock Left, it will
always have the same width, and will always be against the left edge of
the Form, but will get taller or shorter to always fill the Form
vertically.

Dock Right means the same thing but the control will always be pressed
against the right edge of the container.

Dock Top means that the control will always be pressed against the top
of the container. The control will maintain a constant height, but will
grow or shrink its width to always take up the full width of the
container.

Dock Bottom means the same thinge but the control will always be
pressed against the bottom edge of the container.

Dock Fill means that the control will fill the entire container.

If there are several docked controls in one container, they are docked
back to front (in "Z order"): the first control docks to the edge of
the container, the second (in back-to-front order) docks into the space
left in the container after the first control docks, etc.

Now, here's the trick to it: use Panels. The secret (in VS2003, at
least) to making nicely resizing applications is to put your controls
within Panels and then dock the panels.

For example, I have a classic "maintenance screen" form: buttons along
the bottom (including OK and Cancel), ListView on the left with all of
the items that can be maintained, and textboxes and comboboxes on the
right that when you click on an item in the list view, it populates the
controls on the right with properties that the user can change.

What I want is that the buttons always stay along the bottom. As the
form is made taller, the ListView gets taller, but blank space opens up
on the right bottom, because the textboxes, etc, don't grow. As the
form is made wider, the additional width is given to the ListView,
because the controls on the right don't benefit from additional width.
This is how to set it up (in VS2003, .NET 1.1):

Add a Panel to the form, call it buttonPanel. Dock it Bottom and make
it high enough to hold the buttons. Put the buttons in here. The
buttons can have the default Dock and Anchor settings.

Add another panel to the form, call it detailsPanel. Dock it Right and
make it wide enough to hold the text boxes / combo boxes for the item
details. Put the text boxes and combo boxes in here.

Add the ListView to the form. Dock it Fill. It should fill the space up
to the edges of the buttonPanel and the detailsPanel.

Now, as you resize the form, you should see the ListView growing and
shrinking to take up the space.

Now, in VS2005 (.NET 2.0) there is something called LayoutManagers that
allow you to do nicer stuff / use fewer panels-within-panels, but the
same tricks still work in .NET 2.0: decide how you want your Form to
act when it's resized, block it out using docked Panels, then place
controls on the panels.

Oh, and it's nice to your user to use a Splitter (in VS2003) / a
SplitContainer (in VS2005) to allow your user to resize the areas you
allocate to various controls. Get the docking / anchoring working
first, though, so that you understand it... then play with splitters.

You can also try reading this, which I just found:

http://msdn.microsoft.com/library/de...NETVBdev05.asp
Jul 12 '06 #4
aviad wrote:
Thanks very much to both of you John and Bruce
i think i got the principle now
Bruce Wood wrote:
To add to what the others posted, in VS2005, take a look at the
TableLayoutPanel and the FlowLayoutPanel. These can also help with
layout.

Jul 12 '06 #5
I did what you all told me
I worked with pannels, Dock and Anchor
and every thing simmed fine i compiled the project and tried it on
different resolutions on my computer

but when i sent it to a friend he got the project in offset !?!?

i have a tabControl woth 3 tabs
each contains a pannel and in the pannel i pu another form
DockStyle.Fill
the control is placed in the tab using Anchor to all directions
(up,down, left,right)

any ideas?

Jul 13 '06 #6
i forgot to mention that on the other tabs the formed stayed in place

Jul 13 '06 #7

aviad wrote:
I did what you all told me
I worked with pannels, Dock and Anchor
and every thing simmed fine i compiled the project and tried it on
different resolutions on my computer

but when i sent it to a friend he got the project in offset !?!?

i have a tabControl woth 3 tabs
each contains a pannel and in the pannel i pu another form
DockStyle.Fill
the control is placed in the tab using Anchor to all directions
(up,down, left,right)

any ideas?
None, other than that the offending Panel isn't anchored correctly, or
is somehow placed on the Form itself, rather than on the TabPage. I've
never seen that behaviour.

Jul 14 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Daniele petracca | last post by:
<SCRIPT TYPE="text/javascript"> if (screen.width==1024) { distanza=100; sinistra=100; } else { distanza=10; sinistra=10; } document.write(screen.width);
28
by: jonjon | last post by:
Hi, I want to be able to define the right property of my absolute positionned elements... for example if a button is 50px left and 150px right, it will resize when the page is resized. This is...
16
by: Dan V. | last post by:
How do you do a css 2 column layout with header and footer, with the 2nd column auto-stretching so entire page looks good for 800 x 600 resolution as min. and 1024 x 768 resolution as a max? ...
7
by: mukeshgupta.WD | last post by:
Hi, i have seen in many web sites, the size of pages are automatically resized according to screen resolution. generally we create web layout for 800x600 but if we view it in1024x768 then the...
17
by: stubbsie | last post by:
Hi, I have redesigned our official public government website in .net and it has taken me a few months to redo. I have been the sole designer of the website from its humble beginnning a few years...
2
by: one.1more | last post by:
Hello, I have the following code but its not working. i want my site to be accessible only if the visitors resolution is 1024 x 768 or higher and only if they are using internet explorer. the...
11
by: Doc John | last post by:
I have a Windows application developed in VS.Net 2002 and upgraded to VS2005, and when I try to run it in an 800x600 resolution, it doesn't load completely (plus its memory usage is really high)....
7
by: somacore | last post by:
Hi, I have some code, below, that takes input from a combobox and is supposed to parse it and display it. However, it doesn't work. I can't figure out why. The combobox is the one for the...
6
by: | last post by:
Hi, I need to get the the display monitor native resolution.I have tried SystemInformation.PrimaryMonitorSize. it is giving the exisiting resolution of the display monitor that is connected....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.