[DUG] Storing extra data with a component

Todd Martin toddm at kol.co.nz
Fri Jun 10 11:03:21 NZST 2005


Hi Phil

There is another way. Override DefineProperties() and create two private 
methods SaveObject()/LoadObject()

procedure TMyComponent.DefineProperties(Filer: TFiler);
begin
   Filer.DefineProperty('Object',LoadObject,SaveObject,assigned(Object));
end;

procedure TMyComponent.LoadObject(AReader: TReader)
begin
  if Object.InheritsFrom(TCollection) then
  begin
    AReader.ReadCollection(TCollection(Object));
  end;
end;

procedure TMyComponent.SaveObject(AWriter: TWriter);
begin
  if Object.InheritsFrom(TCollection) then
  begin
    AWriter.WriteCollection(TCollection(Object));
  end;
end;

----- Original Message ----- 
From: "Phil Scadden" <p.scadden at gns.cri.nz>
To: "NZ Borland Developers Group - Delphi List" <delphi at ns3.123.co.nz>
Sent: Friday, June 10, 2005 10:47 AM
Subject: Re: [DUG] Storing extra data with a component


>> i.e. by their parent object. How will descending your TCollection class
>> help?
>
> Descending TMycomponent so type of TCollection is explicit. Actually too
> much pain in this so instead of doing my own stream storage. Should have
> gone that way from start.
>
> ----------------------------------------------------------
> Phil Scadden, Institute of Geological and Nuclear Sciences
> 764 Cumberland St, Private Bag 1930, Dunedin, New Zealand
> Ph +64 3 4799663, fax +64 3 477 5232
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
> 



-- 
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.5.1 - Release Date: 2/06/2005



More information about the Delphi mailing list