Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Icon in TCustomControl integrieren (https://www.delphipraxis.net/58438-icon-tcustomcontrol-integrieren.html)

K-Asche 7. Dez 2005 07:27


Icon in TCustomControl integrieren
 
Hi@all,

ich schreibe mir gerade ein eigenes Control abgeleitet von TCustomControl.
Wie kann ich in dieses Control nun ein Icon einfügen?

Gruß

Karsten

Ghostwalker 7. Dez 2005 07:46

Re: Icon in TCustomControl integrieren
 
Das ist sehr einfach. Bau einfach eine Property in deine Komponente ein.

Beispiel (Rumpf)

Code:
   private
       fIcon : TIcon;
       procedure SetIcon(const value:TIcon);
      :
      :
   published Icon : TIcon read ficon write SetIcon;
      :
      :


  constructor xyz.create;
  begin
    fIcon := TIcon.create;
    :
    :
  end;

  destructor xyz.destroy;
  begin
    ficon.free;
  end;

   procedure xyz.SetIcon(const Value:TIcon);
   begin
     ficon.assign(value);
   end;

Jetzt brauchst du das Icon nur noch beim Zeichnen berücksichtigen.

K-Asche 7. Dez 2005 07:50

Re: Icon in TCustomControl integrieren
 
Meine Icons befinden sich aber in einer ImageList und sind als Ressourcen eingebunden.

Kroko1999 7. Dez 2005 07:57

Re: Icon in TCustomControl integrieren
 
in der Komponente Paint überschreiben und dort zeichnen

Delphi-Quellcode:
procedure TmyCompo.Paint; override;
...
procedure TMyCompo.Paint;
begin
  inherited;
  ImageList.draw (Canvas,2,2,True);  
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:12 Uhr.

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