-2

Delphi 10.1 Berlin seems to have widely defective ScaleBy. It looks like Vcl.ComCtrls.pas has a bunch of scaling bugs. Has anyone fixed it?

Controls on PageControl are double scaled. Checkbox boxes and radio buttons are not scaled. Statusbars seem to be scaled by Scaleby but not scaled by DPI.

When font scale set in Windows 7 is 125% scaling also breaks and seems to go to 125% * Scale

The PageControl problem seems to be in VCL.ComCtrls.pas, new fn TPageControl.ChangeScale that calls its inherited method CustomTabsheet.ChangeScale. So everything on a tabsheets gets ChangeScale twice.

Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94
Henry Crun
  • 235
  • 1
  • 11
  • 1
    I can't confirm this (Delphi 10.1 Berlin build 24.0.25048.9432). Are you perhaps calling a function that scales the button and then calls another function that scales the button (or e.g. a panel it is on) too? Could you create a [MCVE]? – Rudy Velthuis Jul 02 '17 at 04:21
  • It doesn't do it in XE2 (I am migrating program from xe2). An XE10 simple test doesn't do it. My routines are not being called twice. Unfortunately Change scale is re-entrant and iterating, so very hard to see where the extra call is coming from, and diff on xe2 vs xe10 vclcontrol.pas didn't show obvious difference – Henry Crun Jul 02 '17 at 05:09
  • There is no such thing as XE10. Unless you can produce a reproducible test case, how are we going to help? – David Heffernan Jul 02 '17 at 06:58
  • Don't be snarky David. Sadly producing a reproducible test case, is functionally the same as finding where the problem is i.e over 5 hours of stepping through and breakpoints, well for me it is..... Someone might well have seen it before and had to fix it, – Henry Crun Jul 02 '17 at 07:33
  • We can't possibly know whether we've seen the same thing until you produce a reproduction. Perhaps we saw a similar but different bug. Don't mistake stack overflow as an excuse not to perform basic debugging. – David Heffernan Jul 02 '17 at 07:58
  • @HenryCrun: There is no XE10. I assume you meant, in this case, 10.1 Berlin. – Rudy Velthuis Jul 02 '17 at 13:15
  • OK, I can reproduce it in 10.1 Berlin for a button on a tabsheet on a TPageControl (but not for a button on, say, a panel, as I tried first). And it seems to be fixed in 10.2 Tokyo. – Rudy Velthuis Jul 02 '17 at 13:23

1 Answers1

-1

The problem seems to be in VCL.ComCtrls.pas, new fn TPageControl.ChangeScale that calls its inherited method CustomTabsheet.ChangeScale. So everything on a tabsheets gets ChangeScale twice. Anyone know if this has changed in 10.2?

procedure TPageControl.ChangeScale(M, D: Integer; isDpiChange: Boolean);
var
  I: Integer;
begin
  inherited ChangeScale(M, D, isDpiChange);
  for I := 0 to FPages.Count - 1 do
    TTabSheet(Fpages[I]).ChangeScale(M, D, isDpiChange);
end;

Example: Button 2 is on tabsheet of PageControl1.

unit ScaleBy1;

  interface

  uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.ComCtrls;

  type
    TForm1 = class(TForm)
      Button1: TButton;
      PageControl1: TPageControl;
      TabSheet1: TTabSheet;
      TabSheet2: TTabSheet;
      Button2: TButton;
      procedure Button1Click(Sender: TObject);
      procedure Button2Click(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;

  var
    Form1: TForm1;

  implementation

  {$R *.dfm}

  procedure TForm1.Button1Click(Sender: TObject);
  begin
    ScaleBy(140,100);
  end;

  procedure TForm1.Button2Click(Sender: TObject);
  begin
    ScaleBy(100,140);
  end;

  end.
Henry Crun
  • 235
  • 1
  • 11