DPI settings and window sizing


D

Darren

Hi,

If I am running an application on a system that is using Large Fonts
(screen resolution set to 120 DPI) and with the Form's AutoScale
property set to true, how can I get (or calculate) what a window's size
would be before the system auto-scales it?

For example if the form's size is set to 300x200, a 120 DPI system will
auto-scale the form and the actual size will change to 381x237. I need
to know what the original size was before the form was scaled. Granted
in this case, I know that I started out at 300x200, but the form in my
program is sizeable. If the user resizes the form and closes it, I
want to be able to save the size so that the form will open with the
exact same size the next time the program is run. I can't save the
"381x237" value, as that would cause the form to auto-scale to an even
larger size.

How can I determine the original "base" size of the form?

Thanks in advance!
--Darren
 
Ad

Advertisements

B

Bob Powell [MVP]

For systems that require accurate measurement you should consider
positioning text etc using a real-world measurement system such as points or
millimeteres. These have consistent results regardless of the screen
resolution.

A caveat is that many @plug and [email protected] monitors do not correctly report their
sizes so they use standard resolutions such as 96 DPI just to shut the
system up from asking stupid questions. These shortcuts can cause havoc when
you need to create a real WYSIWYG system.


--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
K

Ken Halter

Bob Powell said:
For systems that require accurate measurement you should consider
positioning text etc using a real-world measurement system such as points
or millimeteres. These have consistent results regardless of the screen
resolution.

A caveat is that many @plug and [email protected] monitors do not correctly report
their sizes so they use standard resolutions such as 96 DPI just to shut
the system up from asking stupid questions. These shortcuts can cause
havoc when you need to create a real WYSIWYG system.


--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

Hard to believe, in this day and age, someone hasn't done something about
the "Large Font" issue (like kill it completely <g>)
http://www.divsoft.com/lfs/

fwiw, in VB6, we have twips (may be .Net too... dunno)... since there've
been 1440 twips per inch since day one (the printing industry set that
standard), measurement was a breeze, regardless of actual screen resolution.
 
Ad

Advertisements

B

Bob Powell [MVP]

Hi Ken,
..NET has the following real-worls layout systems.

Inches, Millimeters, Points, Display (72 DPI) and Document (300 DPI).

I use a simple routine to convert to or from twips.

See http://www.bobpowell.net/coordinatesystems.htm

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

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