How to make my application resolution aware?

  • Thread starter Thread starter aviad
  • Start date Start date
A

aviad

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
 
aviad said:
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
 
aviad said:
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/default.asp?url=/library/en-us/dnvs05/html/NETVBdev05.asp
 
aviad said:
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.
 
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?
 
aviad said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top