В двух словах: захотел скомпоновать ряд свойств под общим именем в компоненте который пишу. Получилось примерно это (привожу самое главное):
unit ButtonPanel;
...
type
TButtonPanel = class;
TShifts = class(TPersistent)
private
FCaptionDX: integer;
FCaptionDY: integer;
FAOwner : TButtonPanel;
procedure SetCaptionDX(const Value: integer);
procedure SetCaptionDY(const Value: integer);
public
constructor Create(AOwner: TButtonPanel);
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property CaptionDX : integer read FCaptionDX write SetCaptionDX;
property CaptionDY : integer read FCaptionDY write SetCaptionDY;
end;
TButtonPanel = class(TPanel)
...
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
protected
procedure Paint; override;
published
property Shifts : TShifts read FShifts;
end;
procedure Register;
implementation
...
procedure Register;
begin
RegisterComponents('Ed', [TButtonPanel]);
end;
constructor TButtonPanel.Create(AOwner: TComponent);
begin
inherited;
FShifts := TShifts.Create(self);
...
end;
destructor TButtonPanel.Destroy;
begin
...
FShifts.Free;
inherited;
end;
...
procedure TShifts.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TShifts then
begin
FCaptionDX := TShifts(Source).CaptionDX;
FCaptionDY := TShifts(Source).CaptionDY;
end;
end;
constructor TShifts.Create(AOwner: TButtonPanel);
begin
FAOwner := AOwner;
FCaptionDX := 0;
FCaptionDY := 0;
end;
destructor TShifts.Destroy;
begin
inherited;
end;
procedure TShifts.SetCaptionDX(const Value: integer);
begin
FCaptionDX := Value;
FAOwner.Invalidate;
end;
procedure TShifts.SetCaptionDY(const Value: integer);
begin
FCaptionDY := Value;
FAOwner.Invalidate;
end;
end.
Чего-то не сохраняет CaptionDX и CaptionDY в DFM-файл :(
Пробовал и
property CaptionDX : integer read FCaptionDX write SetCaptionDX stored true;
property CaptionDY : integer read FCaptionDY write SetCaptionDY stored true;
и
property CaptionDX : integer read FCaptionDX write SetCaptionDX nodefault;
property CaptionDY : integer read FCaptionDY write SetCaptionDY nodefault;
,
не помогает.
Помогите плиз!