Skip to content

In AutoScale the "margin" should be DPI scaled #1205

@pyscripter

Description

@pyscripter
procedure TBaseVirtualTree.AutoScale();

// If toAutoChangeScale is set, this method ensures that the default node height is set correctly.

var
  lTextHeight: TDimension;
begin
  if HandleAllocated and (toAutoChangeScale in TreeOptions.AutoOptions) then
  begin
    Canvas.Font.Assign(Self.Font);
    lTextHeight := Canvas.TextHeight('Tg') + 2;

Shouldn't the last statement be:

    lTextHeight := Canvas.TextHeight('Tg') + ScaledPixels(2);

My laptop has a scaling factor of 300% and that scaling may make a difference in the visual density of rows.

Looking at TControl.Change scale I saw that the FCurrentPPI is updated after the font is changed. So the following would work also when ParentFont is False, since CurrentPPI gets the PPI from the Window handle.

    lTextHeight := Canvas.TextHeight('Tg') + MulDiv(2, CurrentPPI, 96);

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions