views:

34

answers:

1

Hi,

I have a program that has a SIZE of 800x600.

I want to make this program expand if it is maximized, so that all the elements(buttons, picturebox's) change size to fit the new ratio depending on the users windows screen resolution.

The way I am thinking to approach this is to take the users screen resolution and manual change the size of everything, and do this for all common resolutions, if a user has some rare resolution, ill just make it so the maximize/minimize buttons are disabled.

But this will be very very time consuming as there are lots of elements in the forms, and their are multiple forms.....

Basically, is there a shortcut? Perhaps a built in feature or some kind of add in for VS2008.

What are some methods to tackle this issue?

A: 

ASs you've probably noted, almost every Windows program has a maximize button. So this is certainly a common problem, and there are indeed existing solutions.

Typically you don't mess with fixed resolutions. This is really a losing game, if only because the taskbar takes away an unspecified amount of space. Even if you painstakingly did enumerate all different cases, you would probably have to redo it for Windows 8.

Instead, you typically distibute the "extra" space over the different controls. For instance, since your app is a minimum of 800x600, the extra space on a 1024x732 desktop would be 224 horizontally and 132 vertically. Your menu bar most likely already knows how to deal with this: it takes 100% of the extra horizontal space, and 0% of the vertical space. For other controls in your window, you can define similar percentages. Often the precentages assigned are 0% and/or 100%. In WinForms, you just need to tell this to your windows layout engine.

Furthermore, you also should use relative positioning for your controls. For instance, if you have an 100% expandable textedit on the left of your window, and a fixed button on the right, then you should position that button relative to the right edge. In WinForms, this can be achieved via the Anchor property.

MSalters