View Issue Details

IDProjectCategoryView StatusLast Update
0037299LazarusLCLpublic2020-07-05 00:14
ReporterEmil Totev Assigned To 
Status newResolutionopen 
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
Attached Files


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


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);
  I :Integer;

  Procedure DoSetAControlParentFont(AControl :TControl; AATrue :Boolean);
    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;

If AWinControl.ControlCount > 0 then
  For I := 0 to AWinControl.ControlCount - 1 do
    {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
      If TWinControl(AWinControl.Controls[I]).ControlCount > 0 then
        SetChildControlsParentFont(TWinControl(AWinControl.Controls[I]), ATrue);

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