views:

179

answers:

4

I have a C# Windows application (i.e. not a web app) in Visual Studio. The original development environment was a Dell Latitude D800 with a 1920x1200 pixel screen. Since the large number of pixels made the text very small, I adjusted lots of different default fonts in the name of readability.

I have moved development to new laptop, a Latitude D630 with 1440x900 display. The app was moved by creating a new project on the new machine, and adding the existing objects/files/etc.

THE PROBLEM is that many of my forms are no longer displaying uniformly. Some are now too large so that items on the right are out of the frame, and others are smaller with excess space on the right of the frame. It is as if the value of a 'pixel' is now different from one form to another. These changes persist when the executable is installed on production machines.

Any idea on what happened, and how to restore order? Thanks.

+3  A: 

A good bet would be to check your font DPI setting. By default its set to 96. Its part of your windows display settings.

Matt Brunell
A: 

As best I understand, that would not explain why some forms are affected differently from others.

SeaDrive
A: 

Winforms contains a lot of technology designed around the problem of making the display of forms reasonably resolution-independent. But a lot of this technology requires you to understand and use it - anchoring, docking, layout panels, and automatic scaling, for instance. If you've misapplied these properties, you often don't know about it until the day that you first test your app at a different resolution.

Unfortunately, there isn't really a magic bullet answer to the question "why are my forms screwed up?" Your forms are screwed up because resolution-independence wasn't designed into them. There's a whole host of possible problems: you could have controls anchored to the wrong things, someone could have "fixed" a layout problem by overriding automatic scaling on a control, really, it's endless.

Often, the best way to fix this kind of problem in a legacy app is to slowly build up a prototype duplicate of the offending form in a test application and watch its behavior when you resize it and change your screen resolution. That'll help you identify how the form should originally have been designed; you can then take what you've learned back to the original form and fix it.

And then design this into your development process from the beginning. One of the reasons that I don't have these problems in the big UI-intensive desktop app I'm building is that I've made every form in the program resizable, and I resize them during testing all the time to see if they're screwing up. I also test with different screen resolutions as a matter of course. These are the kinds of problems that are really hard to solve once they've become systemic; spotting them early keeps a lot of misery out of my life.

Robert Rossney
A: 

Some experimentation reveals that the declared size of a form apparently affects the size of objects in the scale (length and width units per screen inch) of the form when displayed as a maximized MDI child.

I have no idea why it should affect that.

SeaDrive