DPI Scaling

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

A recent (September 2009) purchase of a 17" laptop with a high resolution (1920x1200) screen uncovered problems introduced by screen scaling which I had not previously considered. 

Vista and XP have a user option to adjust the assumed dots per inch (DPI) screen resolution.  Without other knowledge, the system assumes 96 DPI.  If you use a screen with higher resolution, text and other graphics elements will display with 96 DPI scaling and show smaller than expected.  In my case, too small for easy reading with these old eyes. 

My laptop screen is about 14.5" x 9" which works out to 132 DPI.  I set the new resolution to 150% which is about 144 DPI which is very readable and still leaves more screen real estate than on my "old" 13" laptop.

Now to the part that affects Delphi and many other 3rd party apps when screen image elements increase by 150% over their designed sizes. 

bulletEvery TForm has an AutoScroll property which defaults to True and an AutoSize property which defaults to False.  Most apps will therefore appear with the designed pixel size and scroll bars added to adjust for the scaling that has enlarged text and most contained controls.   Swapping these values (so that AutoScroll=false and AutoSize=true) resolves many of the scaling problems.
 
bulletIf the form has many controls placed directly on it, AutoSize will resize the form  just enough to enclose them all, but leave no margins around those touching the edge.  Controls which contain other controls and have  their Alignment property set to alClient work well.  The best way I've found to fix the "no margin" problem is to cut the existing controls, then add  a TBevel aligned as alClient and paste the controls back into it.  You'll have to temporarily set the form's AutoSize to false to expand the form and the TBvel to leave margin space around the other controls. 
 
bulletThe AutoSize property is defined in TControl but it is not exposed in every descendent.  So while a TLabel will automatically expand to show it's caption text,  a TCheckBox will not.  In those cases I have simply expanded the control to fit the larger text and assume that smaller text will still display fully.   

I have converted a couple of programs (Brute Force and WordStuff 2 so far) and don't plan on any massive conversion effort to handle DPI scaling.  Changes will be incorporated as other updates are posted.  If you use DPI scaling and run across a DFF program that needs fixing, let me know.

 

Original:  September 18, 2009

Modified:  May 12, 2018

 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2018, Gary Darby    All rights reserved.