From 58a1d5eef149bcb01eb26430f8385f7b8982605f Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Thu, 10 Apr 2014 17:57:13 +0000 Subject: [PATCH] TCustomEditBtn: fix loading Color. git-svn-id: trunk@44669 - --- lcl/editbtn.pas | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lcl/editbtn.pas b/lcl/editbtn.pas index a4cd2b8060..0aa01fdb9a 100644 --- a/lcl/editbtn.pas +++ b/lcl/editbtn.pas @@ -59,6 +59,7 @@ type FButtonOnlyWhenFocused: Boolean; FDirectInput: Boolean; FEdit: TBeEdit; + FInitialColor: TColor; FIsReadOnly: Boolean; FFlat: Boolean; //Forwarded events from FButton @@ -1250,7 +1251,10 @@ end; procedure TCustomEditButton.SetColor(AValue: TColor); begin - FEdit.Color := AValue; + if (csLoading in ComponentState) then + FInitialColor := AValue + else + FEdit.Color := AValue; end; procedure TCustomEditButton.SetCursor(AValue: TCursor); @@ -1431,6 +1435,11 @@ end; procedure TCustomEditButton.Loaded; begin inherited Loaded; + { + inherited Loaded sends a CM_PARENTFONTCHANGED message, which then + also sets FEdit's color, which is undesired. + } + if GetColor <> FInitialColor then SetColor(FInitialColor); CheckButtonVisible; end; @@ -1469,6 +1478,7 @@ begin FButton := TSpeedButton.Create(Self); FEdit := TBeEdit.Create(Self); inherited Create(AOwner); + FInitialColor := {$ifdef UseCLDefault}clDefault{$else}clWindow{$endif}; BorderStyle := bsNone; FButtonAlign := BaRight; FButtonOnlyWhenFocused := False;