Thema: Delphi Propertys zusammenfassen

Einzelnen Beitrag anzeigen

Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#20

Re: Propertys zusammenfassen

  Alt 10. Feb 2008, 18:07
Hallo,
ich verwende für "Subproperties" folgende Standartvorlage
Delphi-Quellcode:
  TMyPersistent = class(TPersistent)
  private
    FColor : TColor;
    FOnChange : TNotifyEvent;
    procedure SetColor(Value : TColor);
  protected
    procedure DoChange; virtual;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Assign(Source : TPersistent); override;
    property OnChange : TNotifyEvent read FOnChange write SetOnChange;
  published
    property Color : TColor read FColor write SetColor;
  end;


procedure TMyPersistent .SetColor(Value : TColor);
begin
  If FColor<>Value then
    begin
    FColor:=Value;
    DoChange;
    end;
end;


procedure TMyPersistent .DoChange;
begin
  If Assigned(FOnChange) then
    FOnChange(Self);
end;

procedure TMyPersistent.Assign(Source : TPersistent); override;
begin
  If Source is TMyPersistent then
    begin
    FColor:=TMyPersistent(Source).Color;
    end;
  inherited Assign(Source);
end;
I come from outer space to save the human race
  Mit Zitat antworten Zitat