View Issue Details

IDProjectCategoryView StatusLast Update
0037299LazarusLCLpublic2020-07-05 00:14
ReporterEmil Totev Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
OSWindows 
Summary0037299: LCL scaling changes Form.ParentFont property
DescriptionProbably as a side effect of LCL scaling, property Form.ParentFont is reset to False. Easiest to see is when opening a form with ParentFont = True at different screen PPI with "LCL scaling at design time" option On (default). Apart from changes to the various sizes and positions, the ParentFont is set to False.

TagsNo tags attached.
Fixed in Revision
LazTarget
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0035560 new HiDPI Scaling - AutoAdjustLayout(?) Side Effect - ParentFont set to False 

Activities

John Raycheba

2020-07-04 19:46

reporter   ~0123755

This is related to / same as issue 0035560.

As a "work-around" the following procedure can be used at appropriate points to reset the ParentFont.

Procedure SetChildControlsParentFont(AWinControl :TWinControl; ATrue :Boolean = True);
Var
  I :Integer;

  Procedure DoSetAControlParentFont(AControl :TControl; AATrue :Boolean);
    begin
    If AControl is TButton then TButton(AControl).ParentFont := AATrue;
    If AControl is TBitBtn then TBitBtn(AControl).ParentFont := AATrue;
    If AControl is TCheckBox then TCheckBox(AControl).ParentFont := AATrue;
    //If AControl is TColorButton then TColorButton(AControl).ParentFont := AATrue;
    If AControl is TCoolBar then TCoolBar(AControl).ParentFont := AATrue;
    If AControl is TDateTimePicker then TDateTimePicker(AControl).ParentFont := AATrue;
    If AControl is TEdit then TEdit(AControl).ParentFont := AATrue;
    If AControl is TEditButton then TEditButton(AControl).ParentFont := AATrue;
    If AControl is TForm then TForm(AControl).ParentFont := AATrue;
    If AControl is TKGrid then TKGrid(AControl).ParentFont := AATrue;
    If AControl is TLabel then TLabel(AControl).ParentFont := AATrue;
    If AControl is TMaskEdit then TMaskEdit(AControl).ParentFont := AATrue;
    If AControl is TMemo then TMemo(AControl).ParentFont := AATrue;
    //If AControl is TmtrEditbtn then TmtrEditbtn(AControl).ParentFont := AATrue;
    //If AControl is TmtrNVVComboBox then TmtrNVVComboBox(AControl).ParentFont := AATrue;
    If AControl is TPageControl then TPageControl(AControl).ParentFont := AATrue;
    If AControl is TPanel then TPanel(AControl).ParentFont := AATrue;
    If AControl is TPgCtrlBaseChildForm then TPgCtrlBaseChildForm(AControl).ParentFont := AATrue;
    If AControl is TSpeedButton then TSpeedButton(AControl).ParentFont := AATrue;
    If AControl is TStaticText then TStaticText(AControl).ParentFont := AATrue;
    If AControl is TTabSheet then TTabSheet(AControl).ParentFont := AATrue;
    //If AControl is TFormSheet then
    // begin
    // TFormSheet(AControl).ParentFont := AATrue;
      //If Assigned(TFormSheet(AControl).Form) then TFormSheet(AControl).Form.ParentFont := AATrue;
    // end;
    If AControl is TToolBar then TToolBar(AControl).ParentFont := AATrue;
    //If AControl is TVirtualStringTree then TVirtualStringTree(AControl).ParentFont := AATrue;
    end;

begin
If AWinControl.ControlCount > 0 then
  begin
  For I := 0 to AWinControl.ControlCount - 1 do
    begin
    {ParentFont is a Protected Property in TControl -- it should be Public!!}
    //TControl(AWinControl.Controls[I]).ParentFont := ATrue;
    {so must check each control's type!!}
    DoSetAControlParentFont(AWinControl.Controls[I], ATrue);
    {Run recursively }
    If (AWinControl.Controls[I] is TWinControl) then
      begin
      If TWinControl(AWinControl.Controls[I]).ControlCount > 0 then
        begin
        SetChildControlsParentFont(TWinControl(AWinControl.Controls[I]), ATrue);
        end;
      end;
    end;
  end;
end;

Issue History

Date Modified Username Field Change
2020-07-04 09:40 Emil Totev New Issue
2020-07-04 14:38 Bart Broersma Project Lazarus CCR => Lazarus
2020-07-04 19:46 John Raycheba Note Added: 0123755
2020-07-05 00:14 Juha Manninen Relationship added related to 0035560