Jump to content
Sign in to follow this  
dummzeuch

Why does the form size change? (Delphi 11)

Recommended Posts

Given a simple VCL project with an empty VCL form with only the following properties changed from the default:

 

ClientHeight = 200

ClientWidth = 200

Scaled = False

The dfm looks like this:

object Form2: TForm2
  Left = 0
  Top = 0
  Caption = 'Form2'
  ClientHeight = 200
  ClientWidth = 200
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -12
  Font.Name = 'Segoe UI'
  Font.Style = []
  Scaled = False
  PixelsPerInch = 96
  TextHeight = 15
end

and the following code:

type
  TForm2 = class(TForm)
  private
  public
    procedure Loaded; override;
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Loaded;
begin
  Caption := Format('%dx%d', [ClientWidth, ClientHeight]);
  inherited;
end;

The project's manifest is configured for auto generate, runtime themes enabled and Per Monitor v2 DPI awareness.

 

I would have expected the form to show with a Caption of '200x200' regardless of screen resolution or DPI.

But I get this:

image.thumb.png.eb2f791001afe4951c023fcb8d78957e.png

And the form has indeed these dimensions.
 

But why? Even if some scaling took place, I would have expected a client width of 300 rather than 618

 

This is Delphi 11 with Patch 1 applied.

 

That's the latest oddity which is driving me crazy.

Share this post


Link to post
2 minutes ago, Lajos Juhász said:

 

Great, just what I need. GExperts for Delphi 11 just got pushed further into the future. I'm really despairing with this high DPI stuff. Maybe I should just give up and wait for 11.1. There are more fun things to do with my spare time than trying to somehow work around all those bugs in Delphi 11.

  • Sad 1

Share this post


Link to post

Delphi 11.1 also changes the Form font size:

 

-  PixelsPerInch = 96
-  TextHeight = 13
+  TextHeight = 15

 

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
Sign in to follow this  

×