[fpc-pascal] WriteComponent not outputting a hierarchy of components?

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Jun 3 22:55:20 CEST 2010


On Thu, 3 Jun 2010 22:32:38 +0200
Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:

> On 3 June 2010 20:53, Mattias Gaertner wrote:
> >
> > For example a TOpenDialog is not in Controls, so it must be put into
> > GetChildren.
> 
> Sorry, I don't understand. I don't have VCL code here, only LCL & CLX
> code, but TOpenDialog descends from TCustomDialog, which descends from
> TDialog, which descends from TComponent. TComponent can be streamed
> just like any other TComponent or TWinControl descendants, and it will
> be listed in the parent control's Components[] array.

TWinControl.GetChildren only lists the components in the "Controls"
property. This creates the Parent/Child hierarchy in the lfm files. 
A TOpenDialog is listed because TCustomForm.GetChildren adds non
controls.
If you don't use the Parent hierarchy of TReader/TWriter your files
will look like a list instead of a tree.
Nested components will create a tree.
I other words: There are two tree like structures: Owner and Parent.
Parent is optional and will make your stream files more readable.

 
>[...]
> > Yes, and no.
> > Think about Frames, Ancestors and special created components (e.g.
> > TSynEdit creates some components owned by itself).
> 
> And also proves my earlier paint that you don't actually need Owner
> and Parent, and can indeed get away with only Owner (like fpGUI). I
> really can't see why Borland had to introduce both properties when one
> would have sufficed.

Readability.

 
> > you might want to take a look at
> > lazarus/designnonlcl/mywidgetset.pas
> 
> OK, my Lazarus at home is a bit old, so might not have that code.
> Otherwise I'll take a look tomorrow at work.

AFAIR it exists since October.

Mattias



More information about the fpc-pascal mailing list