diff --git a/lcl/controls.pp b/lcl/controls.pp index 37155254d8..0bf8174174 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -1113,6 +1113,7 @@ type procedure CMHintShow(var Message: TLMessage); message CM_HINTSHOW; procedure CMParentBiDiModeChanged(var Message: TLMessage); message CM_PARENTBIDIMODECHANGED; procedure CMParentColorChanged(var Message: TLMessage); message CM_PARENTCOLORCHANGED; + procedure CMParentFontChanged(var Message: TLMessage); message CM_PARENTFONTCHANGED; procedure CMParentShowHintChanged(var Message: TLMessage); message CM_PARENTSHOWHINTCHANGED; procedure CMVisibleChanged(var Message: TLMessage); message CM_VISIBLECHANGED; procedure CMTextChanged(var Message: TLMessage); message CM_TEXTCHANGED; diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 21e8bf10e1..4f5b20b213 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -281,11 +281,7 @@ end; procedure TControl.ParentFontChanged; begin - if csLoading in ComponentState then exit; - - if FParentFont then - Font := FParent.Font; - Perform(CM_PARENTFONTCHANGED, 0, 0); + //kept for compatibility. The real work is done in CMParentFontChanged end; procedure TControl.SetAction(Value: TBasicAction); @@ -762,6 +758,21 @@ begin Color := FParent.Color; end; +{------------------------------------------------------------------------------ + TControl.CMParentFontChanged + + assumes: FParent <> nil +------------------------------------------------------------------------------} +procedure TControl.CMParentFontChanged(var Message: TLMessage); +begin + if csLoading in ComponentState then exit; + + if FParentFont then + Font := FParent.Font; + //call here for compatibility with older LCL code + ParentFontChanged; +end; + {------------------------------------------------------------------------------ TControl.CMShowHintChanged @@ -3522,7 +3533,7 @@ begin begin FParentFont := Value; if Assigned(FParent) and not (csReading in ComponentState) then - ParentFontChanged; + Perform(CM_PARENTFONTCHANGED, 0, 0); end; end; diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 299f568108..a7131adc31 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -4546,7 +4546,7 @@ begin Include(FWinControlFlags, wcfFontChanged); inherited; for i := 0 to ControlCount - 1 do - Controls[i].ParentFontChanged; + Controls[i].Perform(CM_PARENTFONTCHANGED, 0, 0); end; procedure TWinControl.SetColor(Value: TColor); @@ -5989,7 +5989,7 @@ begin AControl.Perform(CM_PARENTCOLORCHANGED, 0, 0); AControl.Perform(CM_PARENTSHOWHINTCHANGED, 0, 0); AControl.Perform(CM_PARENTBIDIMODECHANGED, 0, 0); - AControl.ParentFontChanged; + AControl.Perform(CM_PARENTFONTCHANGED, 0, 0); if AControl is TWinControl then TWinControl(AControl).UpdateControlState else @@ -7273,7 +7273,7 @@ begin TWSWinControlClass(WidgetSetClass).SetFont(Self,Font); NotifyControls(CM_PARENTCOLORCHANGED); for i := 0 to ControlCount - 1 do - Controls[i].ParentFontChanged; + Controls[i].Perform(CM_PARENTFONTCHANGED, 0, 0); FWinControlFlags:=FWinControlFlags-[wcfFontChanged]; end; end;