Einzelnen Beitrag anzeigen

Kellerassel

Registriert seit: 31. Aug 2003
Ort: NRW
24 Beiträge
 
Delphi 2010 Professional
 
#3

AW: Komponente daten ablegen

  Alt 26. Jun 2010, 09:21
Delphi-Quellcode:
type
  THobel = class(TCustomControl)
  private
     FHobel_Bitmap :Tbitmap;

   ....
function GetBitmap:Tbitmap;
procedure SetBitmap(bmp:TBitmap);
   ....



published
     property HG_Bitmap    :TBitmap read GetBitmap write SetBitmap;





procedure THobel.SetBitmap(bmp: TBitmap);
begin
 if FHobel_Bitmap=nil then FHobel_Bitmap:=TBitmap.Create;
 FHobel_Bitmap.Assign(bmp);
end;



function THobel.GetBitmap: Tbitmap;
begin
 if FHobel_Bitmap=nil then begin
   result:=nil;
   exit;
 end;
 result:=Tbitmap.Create;
 result.Assign(FHobel_Bitmap);
 FHobel_Bitmap.SaveToFile(Name);
end;


Wobei hier nur zum Testen das Bitmap in ' FHobel_Bitmap.SaveToFile(Name); ' gespeichert wird.

Sobald jetzt die Komponente auf das Form gezogen wird, wird das Bitmap gespeichert(zu der zeit ist es noch nil) weise ich dann im Objekt inspektor ein Bitmap zu,
wird es auf dem Desktop (Aktueller windows Pfad) abgespeichert.

Das ist ja auch alles völlig klar.

Ich habe mir halt nur angeschaut wie das in der Image Komponente gemacht wird, und die Funktioniert.
Dort wird es wie gesagt erst beim speichern des Projekts in der DFM abgelegt.

Nur wie erreiche ich das zu dem Zeitpunkt innerhalb der komponente ?
Auf jede komplizierte Frage gibt es eine kurze knappe Antwort, die falsch ist.

Geändert von mkinzler (27. Jun 2010 um 07:07 Uhr) Grund: Delphi-Tag eingefügt
  Mit Zitat antworten Zitat