Inconsistent Design Time behaviour

S

Simon Bond

I develop on a workstation running in 96 dpi. When i design my forms in
VS.NET, layout is immaculate and everything looks great. When my client
loads up the software and displays it on their large panel LCD running 120
dpi, the layout all goes to hell.

Now, I previously thought I had a solution for this. By designing your forms
and custom controls in 120 dpi, then when you deploy to regular 96 dpi end
users, everything will look great on both 120 and 96 dpi. Once I reverted
back to a suitable 96 dpi on the workstation and continued building the app,
it appeared as though the fixed layout for 120 remained in place..... at
least for a while. All of a sudden everything has gone to hell, controls
being thrown off forms and out of sight to the user and so on, and now I'm
back at square 1.

Why does the development machine's DPI setting affect the compiled layout of
the application on target machines? I thought half the point of GDI+ was to
make resolution independant layouts so the end user's display will show the
same layout/design as intended regardless of dpi setting.

Is there ANY way to design a Windows form in .NET which will be consistant
across both 96 and 120 dpi? keeping my workstation running in 120 dpi is not
a valid workaround.

Cheers

- Si
 
H

Herfried K. Wagner [MVP]

* "Simon Bond said:
I develop on a workstation running in 96 dpi. When i design my forms in
VS.NET, layout is immaculate and everything looks great. When my client
loads up the software and displays it on their large panel LCD running 120
dpi, the layout all goes to hell.

Did you have a look at the form's 'AutoScale' property?
 
S

Simon Bond

Hi Herfried

Yeah I've tinkered with that a couple times but that seems to make the
design and actual output even less predictable.

I guess the biggest problem is with the custom drawn controls. As a work
around what I'm doing now is:

void OnPaint(..)
{
float scaleX = e.Graphics.DpiX/96f;
float scaleY = e.Graphics.DpiY/96f;
e.Graphics.ScaleTransform(scaleX, scaleY);

... perform measuring opperations, such as creating a rounded box graphics
path...

e.Graphics.ResetTransform();

... i find i have to reset the scaling transform before actually filling a
path, otherwise it does weird stuff where your right and bottom dimensions
of the actual output is thrown way out of proportion. then finally...
e.Graphics.FillPath(brush, roundedbox);

.... output should be ok.

}

That seems to be working OK for now. but control positioning within the IDE
is still being moved within the IDE when i switch between 120 dpi and 96
dpi. like i'll put a richtextbox with X = 8 in a panel in 96. compile, run.
change dpi to 120, restart, open up the project in VS.NET, now X = 16. I've
just turned off grid snapping on a bunch of things so perhaps that will stop
that from happening.

- Si.
 

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

Top