473,887 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3328
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 "maintenanc e 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 "maintenanc e 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
TableLayoutPane l 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
2627
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
7102
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 working fine in Mozilla but it isn't working in Internet Explorer :( Is this a known bug ? do you have any suggestion without using tables or OnResize event ? Best regards,
16
6179
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? Ideally the layout would be centered so it scales better visually. This would be great for me. Thanks,
7
51410
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 page open have wide space on right. Is there any kind of coding to overcome this situation.like when we wiew the page created in 800x600 in 1024x768 resol. then it atomatically resized to full screen without having any scroll on browser.
17
2307
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 ago when no one wanted to even mess with it. Since then I have been steadily maintaining it and improving it. I am about halfway done, and all of a sudden my supervisor won't let me make the website in .net. Our programmers use .net to make web...
2
2363
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 version is not important because i think most people have 5.5+ When i visit my my site with 800 x600 either by using firefox or IE, it redirects me to useie.htm. but if i use firefox with 1024 x 768, it doesnt redirect me to useie.htm. why? can...
11
3858
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). If I minimize, and maximize it, then it'll display correctly. How come? Is there a fix? Thanks.
7
3147
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 resolution code, which specifies how the ticket was closed. The code compiles fine, but the box persists with the number instead of the actual code. Thoughts? if (comboBox12.Text != "") { int ResCode =...
6
5317
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. Please help me out to find the way to get the native resolution of the monitor that is connected -BMK
0
9799
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
11173
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
10770
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9593
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
7988
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
7141
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
5809
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...
2
4238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.