Thema: Delphi TImage als Parent

Einzelnen Beitrag anzeigen

Benutzerbild von uligerhardt
uligerhardt

Registriert seit: 19. Aug 2004
Ort: Hof/Saale
1.735 Beiträge
 
Delphi 2007 Professional
 
#11

Re: TImage als Parent

  Alt 30. Sep 2008, 15:32
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.
Uli Gerhardt
  Mit Zitat antworten Zitat