TCustomEditBtn: fix loading Color.

git-svn-id: trunk@44669 -
This commit is contained in:
bart 2014-04-10 17:57:13 +00:00
parent e3aa48ff3e
commit 58a1d5eef1

View File

@ -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;