Jump to content
Alexander Halser

High-dpi scaling problems with TFrame

Recommended Posts

I've run into a new problem that did not occur to me before. And the reason is that I purchased a new monitor with a somewhat higher resolution. To compensate for that, I have switched the Windows system DPI from 96 to 120. Delphi is running with 120 dpi as well, form designer, too.

 

The symptom:

When a TFrame gets created at runtime and is docked into another form, the first re-scaling of the frame content upon a monitor change is wrong.

 

How to reproduce:

1) Delphi XE 11.3

2) Main monitor has a system scaling of 125% (= 120 dpi)

3) IDE is running at 120 dpi

4) The app starts on the main monitor first (no scale required, because design and runtime dpi are both 120)

5) Form is moved to a different monitor with a higher dpi

 

Screenshots and project source below.

 

Source of the problem:

When examining the internal ChangeScale(M, D, isdpichange) messages, it becomes clear that all TControls (but not the TFrame itself) receive one initial scaling message, that scales to 192 dpi from 96 dpi. This is wrong, because the control currently has a CurrentPPI of 120. As a result, the controls over-scale at the first monitor change.

 

Questions:

Could anyone please test if this bug has been fixed in Delphi 12?

I am in the middle of substantial code changes with a pretty large application and am reluctant to change horses in the middle of the race. If the problem persists in Delphi XE 12, updating the IDE would be an additional effort that I would like to avoid at this point.

 

 

screenshot-source.png

screenshot-1.png

screenshot-2.png

Project2.zip

Edited by Alexander Halser

Share this post


Link to post

For me, the only way to handle all HDPI related problems and bugs, is to use Delphi in DPI-unaware mode and keep all designed forms and frames at 96 dpi. On runtime they scale fine.

Even then Delphi IDE 12.3 on monitor set to 150 % sometimes shows hint too small and moved to top left corner of the screen...

Share this post


Link to post
Quote

use Delphi in DPI-unaware mode

It's a pain, I know. Initially I tried your approach, but then the IDE is fuzzy. Writing code in a fuzzy editor is an even bigger pain.

 

Actually, it has its benefits to develop forms at 120 dpi or even higher. You are less likely to run into runtime scaling problems with labels a tad too short or checkboxes and radio buttons not tall enough to fit the descent of characters like "g" or "y". It's not bad to develop at 120 dpi and there are normally no scaling problems. Unless you go per-monitor-dpi-aware, of course :classic_dry:

Share this post


Link to post

There are several bugs fixed in 12.2 and 12.3 affecting frames.

https://quality.embarcadero.com/browse/RSP-37402

https://quality.embarcadero.com/browse/RSP-39847

https://quality.embarcadero.com/browse/RSP-40110

https://quality.embarcadero.com/browse/RSP-43560

https://embt.atlassian.net/servicedesk/customer/portal/1/RSS-1020

 

Perhaps these will fix your problem, too.

 

I will test your project later when I've found some time to configure my system for monitors with different dpi.

  • Like 2

Share this post


Link to post

I have scaling of 200% and unfortunately I am also forced to run Delphi in DPI-unaware mode. Otherwise TFrame and a couple of other components have several properties scaled incorrectly and every time I edit the DFM it doubles some values.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×