Создаю свой компонент с визуализацией Label в Edit, см. рис.
При компиляции появляется еще одни Label. А при отрисовке формы нельзя скопировать готовый компнонент - выдает ошибку.
Подскажите, как избавиться от дубликата.
t
type
TShowLabel = (Show, Hide);
TEditVisualLabel = class(TEdit)
private
TextLabel : TLabel;
FloatVErt : TFloatAnimation;
FloatSize : TFloatAnimation;
FloatColor : TColorAnimation;
FLabCAp : string;
function GetSHow: TShowLabel;
Procedure SetShow(Value : TShowLabel);
function GetLabelCaption: string;
Procedure SetLabelCaption(Value : string);
function GetLabelFontColor: TAlphaColor;
Procedure SetLabelFontColor(Value : TAlphaColor);
function GetStopValue : Single;
procedure SetStopValue(Value : Single);
function GetStartValue: Single;
procedure SetStartValue(Value : Single);
function GetStopFont: Single;
procedure SetStopFont(Value : Single);
function GetStartFont: Single;
procedure SetStartFont(Value : Single);
{ Private declarations }
protected
procedure Enter(Sender : TObject);
procedure Exi(Sender : TObject);
{ Protected declarations }
public { Public declarations }
published
property LabelFontColor : TAlphaColor read GetLabelFontColor write SetLabelFontColor;
property LabelCaption: string read GetLabelCaption write SetLabelCaption;
property LabelPositionStop : Single read GetStopValue write SetStopValue;
property LabelPositionStart : Single read GetStartValue write SetStartValue;
property LabelSizeStopFont : Single read GetStopFont write SetStopFont;
property LabelSizeStartFont: Single read GetStartFont write SetStartFont;
property LabelVisible : TShowLabel read GetSHow write SetSHow default TShowLabel(1);
constructor Create(aowner: TComponent);override;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TEditVisualLabel]);
end;
constructor TEditVisualLabel.Create(aowner: TComponent);
var
Del: TLabel;
Family,Style,FontColor : TStyledSetting;
begin
inherited Create(AOwner);
TextLabel := TLabel.create(Self);
TextLabel.Parent := self; // Скорее всего, что именно здесь весь затык, почему оно выполняется дважды
TextLabel.StyledSettings := [Family];
TextLabel.Align := TAlignLayout(2);
TextLabel.TextSettings.FontColor := TAlphaColorRec.Silver;
TextLabel.TextSettings.Font.Size := 14;
TextLabel.SetSubComponent(true);
FloatVErt := TFloatAnimation.Create(TextLabel);
FloatVErt.Parent := TextLabel;
FloatVErt.PropertyName := 'Position.Y';
FloatVErt.StopValue := -20;
FloatVErt.StartValue := 0;
FloatSize := TFloatAnimation.Create(TextLabel);
FloatSize.Parent := TextLabel;
FloatSize.PropertyName := 'TextSettings.Font.Size';
FloatSize.StopValue := 11;
FloatSize.StartValue := 14;
FloatColor := TColorAnimation.Create(TextLabel);
FloatColor.Parent := TextLabel;
FloatColor.PropertyName := 'TextSettings.FontColor';
FloatColor.StartValue := TAlphaColorRec.Silver;
LabelFontColor := TAlphaColorRec.Black;
LabelVisible := TShowLabel(0);
TextLabel.Align := TAlignLayout(2);
//TextLabel.Width := 5000;
//FloatColor.StopValue := LabelFontColor;
OnExit := Exi;
OnEnter := Enter;
end;
procedure TEditVisualLabel.Enter(Sender : TObject);
begin
inherited;
if TextLabel.Position.Y<>FloatVErt.StopValue then
begin
FloatVErt.Inverse := false;
FloatVErt.Start;
FloatSize.Inverse := false;
FloatSize.Start;
FloatColor.Inverse := false;
FloatColor.Start
end;
end;
procedure TEditVisualLabel.Exi(Sender: TObject);
begin
inherited;
if (Self.Text='') and (TextLabel.Position.Y<>0) then
begin
FloatVErt.Inverse := true;
FloatVErt.Start;
FloatSize.Inverse := true;
FloatSize.Start;
FloatColor.Inverse := true;
FloatColor.Start
end;
end;
function TEditVisualLabel.GetLabelCaption: string;
begin
result := TextLabel.Text;
end;
function TEditVisualLabel.GetLabelFontColor: TAlphaColor;
begin
Result := FloatColor.StopValue;
end;
function TEditVisualLabel.GetSHow: TShowLabel;
begin
if TextLabel.Visible then
Result := TShowLabel(0)
else
Result := TShowLabel(1);
end;
function TEditVisualLabel.GetStartFont: Single;
begin
Result := FloatSize.StartValue;
end;
function TEditVisualLabel.GetStartValue: Single;
begin
Result := FloatVErt.StartValue;
end;
function TEditVisualLabel.GetStopFont: Single;
begin
Result := FloatSize.StopValue;
end;
function TEditVisualLabel.GetStopValue: Single;
begin
Result := FloatVErt.StopValue;
end;
procedure TEditVisualLabel.SetLabelCaption(Value: string);
begin
TextLabel.Text := Value;
end;
procedure TEditVisualLabel.SetLabelFontColor(Value: TAlphaColor);
begin
FloatColor.StopValue :=value;
end;
procedure TEditVisualLabel.SetShow(Value: TShowLabel);
begin
if Value = TShowLabel(0) then
TextLabel.Visible := true
else
TextLabel.Visible := False;
end;
procedure TEditVisualLabel.SetStartFont(Value: Single);
begin
FloatSize.StartValue := Value;
TextLabel.TextSettings.Font.Size := Value;
end;
procedure TEditVisualLabel.SetStartValue(Value: Single);
begin
FloatVert.StartValue := Value;
end;
procedure TEditVisualLabel.SetStopFont(Value: Single);
begin
FloatSize.StopValue := Value;
end;
procedure TEditVisualLabel.SetStopValue(Value: Single);
begin
FloatVert.StopValue := Value;
end;
end.