Einzelnen Beitrag anzeigen

Muetze1
(Gast)

n/a Beiträge
 
#21

Re: Bild in eine Buttonkomponente??

  Alt 18. Feb 2008, 19:49
Das bedeutet du weisst nur nicht wie man eine Eigenschaft definiert die ein Bild aufnimmt um es dann auch zum Zeichnen zu nutzen?

Delphi-Quellcode:
type
  TButttonKompo = class(TCustomControl)
  private
    fBild: TBitmap;
    procedure SetBild(AValue: TBitmap);
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    procedure Paint; override;
  published
    property Bild: TBitmap read fBild write SetBild;
  end;

...

constructor TButtonKompo.Create(AOwner: TComponent)
begin
  inherited;

  fBild := TBitmap.Create;
end;

destructor TButtonKompo.Destroy;
begin
  fBild.Free;

  inherited;
end;

procedure TButtonKompo.SetBild(AValue: TBitmap);
begin
  fBild.Assign(AValue);
  Invalidate;
end;

procedure TButtonKompo.Paint;
begin
  if not fBild.Empty then
    self.Canvas.Draw(0, 0, fBild);
end;
So, das ist alles. Ohne Gewähr, da hier im Forum getippt.
  Mit Zitat antworten Zitat