views:

183

answers:

2

I have developed a 1024 *780 resolution screen in Windows Forms, but some say that it does not fit properly at higher resolutions. Is there any way to handle this?

Is there a way to make Windows Forms applications look the same at ALL resolutions?

A: 

This is the sort of thing that makes you say "there's got to be a better way."

My solution for this one time was to declare a global ScalingFactor variable that was tied to the current screen resolution. Then, the sizes of every visual element were multiplied by that factor.

So, if I designed my form for resolution A, and resolution B is 1.2x larger, the width of window A will be with * 1.2, the fonts will be fontSize * 1.2, the textbox dimensions will be dimensions * 1.2.

Not fun.

There may be 3rd party tools that you can buy and will perform this scaling.

One other thing to check before you run down any of these roads is whether it is actually the screen resolution or the dpi settings that are causing it to look bad. Usually a higher resolution will only make it look smaller, but an atypical dpi, such as when the user selects "large fonts" will wreak havoc.

Jay
Just scaling everything by X factor is not the correct solution. Strategy is like there are certain controls on the form that are possible contenders for scaling and others are not. So scaling applies only to these controls.3rd party tools such as devexpress layout controls etc follow this strategy.
Aseem Gautam
In the absence of 3rd party tools, as when doing by hand, one can of course selectively scale.For an already-designed application, such as this, where the user isn't going to swap in all different controls from a 3rd party, the need would really be for a container control of some kind that can wrap everything in the form and scale it all uniformly.
Jay
+2  A: 

My recommendation is not so much to "make it look the same" on all screens, but rather to design the GUI so it scales up and down more gracefully. Layout managers, docking, and anchors are your friends in Winforms. The TableLayoutPanel is quite useful for this sort of thing. Splitters also help...

Finally, this is one of those problems that WPF sets out to solve. WPF makes extensive use of layout managers. It feels much more like Java or GTK than Winforms or even VB (old school VB).

Nate