Einzelnen Beitrag anzeigen

Alter Mann

Registriert seit: 15. Nov 2003
Ort: Berlin
946 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#5

Re: Eigene Eigenschaften beim Vererben

  Alt 11. Dez 2004, 16:53
Hi,

versuche es so:

Delphi-Quellcode:
 type TMyNewForm = class(TButton)
    private
      FImage: TImage;
      procedure SetPicture(Value: TPicture);
      function GetPicture : TPicture;
    public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;

    published
     property Hintergrundbild: TPicture read GetImage write SetImage;
  end;

constructor TMyNewForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FImage := TImage.Create(Self);
  FImage.Parent := Self;
end;

destructor TMyNewForm.Destroy;
begin
  FreeAndNil(FImage);
  inherited Destroy;
end;

procedure TMyNewForm.SetPicture(Value: TPicture);
begin
  if FImage.Picture <> Value then FImage.Picture.Assign(Value);
end;

function TMyNewForm.GetPicture: TPicture;
begin
  Result := FImage.Picture;
end;
  Mit Zitat antworten Zitat