[Lazarus] LCL High-DPI

Ondrej Pokorny lazarus at kluug.net
Mon Feb 20 17:46:13 CET 2017


I'd like to announce that I finished the concept of DPI scaling in 
Lazarus / LCL.

It's quite easy for the programmer. Documented here: 
http://wiki.lazarus.freepascal.org/High_DPI (details are in "High DPI in 
Lazarus 1.7 and above").

1.) I made the Lazarus IDE High-DPI aware - the IDE itself and its 
windows should scale correctly.

2.) To make your own application use the new LCL scaling and to make 
sure your layouts don't get destroyed, do the following:

a.) Make sure you don't change the system DPI settings during the proccess.
b.) Update the IDE to the latest trunk and rebuild it.
c.) Open your project in the IDE.
d.) Enable LCL scaling for your application DPI awarness in Project 
Options -> Application -> "Use LCL scaling (Hi-DPI).
e.) On Windows: enable DPI awarness in Project Options -> Application. 
Decide if you want to support per monitor DPI awarness or not.
f.) Make sure TForm.Scaled=True for all your forms (default value).
g.) Make sure you use TControl.ScaleCoord() or ScaleCoord96() to scale 
coordinates during the run-time.

And you are ready. Your forms will scale both in runtime and design time 
nicely.

For those who followed my last announcement: as Zeljko and Michael 
requested, I removed the LCLScaleForms define and introduced the 
Application.Scaled property instead (that you set in step 2d). The 
default value is Application.Scaled=False.

If you keep Application.Scaled=False, there won't be any changes in your 
application.

Please report issues or comment on problems. I have still time to change 
things until Lazarus 1.8 is out (you can expect RC1 in April).

Ondrej



More information about the Lazarus mailing list