Delphi-PRAXiS
Seite 2 von 2     12   

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 TImage als Parent (https://www.delphipraxis.net/121567-timage-als-parent.html)

uligerhardt 30. Sep 2008 15:32

Re: TImage als Parent
 
Zitat:

Zitat von Hawkeye219
auch durch Ableiten kann man aus einem TImage keinen TWinControl-Nachfolger machen. Es wird also weder über ein Controls-Array verfügen, noch kann es Parent eines anderen Controls werden. Die erste Überlegung von Julius (Beitrag #2) war somit richtig.

Stimmt. Da stand ich wohl auf dem Schlauch. :-)

Also Aggregation, etwa so:
Delphi-Quellcode:
  TImagePanel = class(TCustomPanel)
  private
    FImage: TImage;
  public
    constructor Create(AOwner: TComponent); override;
    property Image: TImage read FImage;
  end;

constructor TImagePanel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  AutoSize := True;
  FImage := TImage.Create(Self);
  FImage.Parent := Self;
end;
Das funktioniert mit Erzeugen zur Laufzeit. Für Designzeit-Unterstützung braucht's wohl noch etwas Feinschliff. :mrgreen:

m.r.m. 30. Sep 2008 15:42

Re: TImage als Parent
 
Zitat:

Zitat von uligerhardt
Also Aggregation, etwa so:
Delphi-Quellcode:
  TImagePanel = class(TCustomPanel)
  private
    FImage: TImage;
  public
    constructor Create(AOwner: TComponent); override;
    property Image: TImage read FImage;
  end;

constructor TImagePanel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  AutoSize := True;
  FImage := TImage.Create(Self);
  FImage.Parent := Self;
end;
Das funktioniert mit Erzeugen zur Laufzeit. Für Designzeit-Unterstützung braucht's wohl noch etwas Feinschliff. :mrgreen:

Das ist bei mir aber nicht transparent.


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:51 Uhr.
Seite 2 von 2     12   

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