Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Bild in eine Buttonkomponente?? (https://www.delphipraxis.net/108658-bild-eine-buttonkomponente.html)

Muetze1 18. Feb 2008 19:49

Re: Bild in eine Buttonkomponente??
 
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.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:29 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz