[Lazarus] Fwd: Need help in streaming components

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Dec 15 11:49:10 CET 2014


On Mon, 15 Dec 2014 07:34:12 -0300
Glaucos Ginez <glaucosginez at gmail.com> wrote:

> Try TObjectList.

That does not support streaming.

 
>[...]
> > I want my TClass1 can contain many TClass2. It means that number of
> > TClass2 in TClass1 is not fixed.
> >
> > I've tried to use TComponentList, but it does not work. I knew that
> > TCollection supports streaming, however, TClass1 and TClass2 must be
> > TComponent.

The trick is overriding some TComponent methods.

TClass1
    procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
TClass2
    procedure SetParentComponent(Value: TComponent); override;
    function GetParentComponent: TComponent; override;
    function HasParent: Boolean; override;

See for example
lazarus/examples/designnonlcl/mywidgetset.pas
class TMyWidget


Mattias




More information about the Lazarus mailing list