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 Speichern einer Komponente mit Bild (https://www.delphipraxis.net/108804-speichern-einer-komponente-mit-bild.html)

monty.ms 19. Feb 2008 20:26


Speichern einer Komponente mit Bild
 
Hallo,

Ich hab hier ein kleines Problem, mit dem ich nicht ganz zurecht komme:

Ich hab diese Klasse:
Delphi-Quellcode:
type
  TTest = class(TComponent)
  private
    FImage: TImage;
  published
    property Image: TImage read FImage write FImage;
  end;
Als erstes erstell ich ein Objekt der Klasse:
Delphi-Quellcode:
 TestComponent := TTest.Create(Form1);
 TestComponent.Image := TImage.Create(Form1);
... dann lad ich das Bild hinzu:
Delphi-Quellcode:
 OpenDialog1.Execute;
 TestComponent.Image.Picture.LoadFromFile( OpenDialog1.FileName );
Und anschließend speicher ich die Komponente:
Delphi-Quellcode:
 tmpStream := TFileStream.Create('C:\test.dat',fmCreate);
 Try
  tmpStream.WriteComponent( TestComponent );
 Finally
  tmpStream.Free;
 End;
Aber aus irgendeinem Grund, speichert er das Bild nicht mit ab. Das Laden der Komponente funtioniert. Man sieht halt schon an der Größe der gespeicherten Datei, dass da was fehlt.

Ich hab zum Test mal, ein Objekt der Klasse TImage gespeichert (anstatt TTest). Das hat funktioniert. Wieso das hier nicht?

Danke schonmal für jede Hilfe :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 21: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