View Issue Details

IDProjectCategoryView StatusLast Update
0018233LazarusOtherpublic2011-09-20 03:53
ReporterlainzAssigned ToJuha Manninen 
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionno change required 
Product Version0.9.29 (SVN)Product Build 
Target VersionFixed in Version 
Summary0018233: ScaleDPI: unit for making Windows 7 High DPI Applications
DescriptionThis is a procedure like ScaleBy to scale Forms and Controls position and size, it uses ScaleX and ScaleY (http://msdn.microsoft.com/en-us/library/dd464660(v=VS.85).aspx) because those functions reads the system DPI configuration, so the scaling is relative to DPI and works for making Windows 7 High DPI Applications.

Just a procedure ScaleControl(Control: TControl; FromDPI: Integer);

Download and compile the attached file, it contains the scaledpi.pas with the procedure ScaleControl, the project file show how to use the procedure :)

To test if it works change your screen DPI in the Control Panel (additional information how to change your screen DPI at the first msdn link ^^)
Additional InformationIn a Form the "FromDPI" value must be defined by the designer (i wish a property in the Object Inspector "FromDPI" or "DesignedDPI" and call ScaleControl when the form is being created automatically :).

const
  FromDPI=96; // if you designed the form at 96 dpi (100%).

{ FromDPI=144; if you designed the form at 144 dpi (150%): the procedure scale down the size of the form and controls if you are running in a lower dpi }

then OnCreate event:

if FromDPI <> Screen.PixelsPerInch then begin
  ScaleControl(Self,FromDPI);
end;

This unit uses some code used in ScaleBy (http://bugs.freepascal.org/view.php?id=17250) to recursively scale controls inside TPanel and other controls.
TagsHighDPI, scale
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0017250 closedPaul Ishenin [PATCH] Add ScaleBy and ChangeScale to LCL 
related to 0020244 closedJuha Manninen Lazarus GUI issues in Windows running in High DPI 

Activities

2010-12-16 20:35

 

scaledpi.zip (97,152 bytes)

Vincent Snijders

2010-12-17 09:13

manager   ~0044290

Last edited: 2010-12-17 09:14

Thank you for the example how to use the Scaling in Windows 7.

Why did you create this feature request? Feel free to add this example to the wiki.

Do you want to change something in Lazarus IDE or the LCL?

lainz

2011-08-22 21:09

reporter   ~0051032

Wiki:
http://wiki.freepascal.org/High_DPI

>>Do you want to change something in Lazarus IDE or the LCL?

If possible make Lazarus IDE High DPI aware application for Windows.

Juha Manninen

2011-09-19 10:00

developer   ~0052015

Lazarus behaves now better with High DPI. See related issues.

Issue History

Date Modified Username Field Change
2010-12-16 20:35 lainz New Issue
2010-12-16 20:35 lainz File Added: scaledpi.zip
2010-12-16 20:35 lainz Widgetset => Win32/Win64
2010-12-17 03:54 lainz Tag Attached: scale
2010-12-17 09:08 Vincent Snijders LazTarget => -
2010-12-17 09:08 Vincent Snijders Status new => acknowledged
2010-12-17 09:08 Vincent Snijders Relationship added related to 0017250
2010-12-17 09:13 Vincent Snijders Note Added: 0044290
2010-12-17 09:13 Vincent Snijders Status acknowledged => feedback
2010-12-17 09:14 Vincent Snijders Note Edited: 0044290
2011-06-28 15:39 lainz Tag Attached: HighDPI
2011-08-22 21:09 lainz Note Added: 0051032
2011-09-19 09:55 Juha Manninen Relationship added related to 0020244
2011-09-19 10:00 Juha Manninen Status feedback => resolved
2011-09-19 10:00 Juha Manninen Resolution open => no change required
2011-09-19 10:00 Juha Manninen Assigned To => Juha Manninen
2011-09-19 10:00 Juha Manninen Note Added: 0052015
2011-09-20 03:53 lainz Status resolved => closed