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

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Jun 3 22:32:38 CEST 2010


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.

As a test I quickly created a LCL application and used the
TraverseComponents() procedure I listed earlier. TOpenDialog was
dropped on the form with a few other controls, and indeed (as I
expected) it was listed in the Components[] array. Here is the LCL
test app output.

-------------------------------
tmp $ ./project1
Label1
Button1
Memo1
GroupBox1
Edit1
CheckBox1
Button2
OpenDialog1
-------------------------------


> 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.

> 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.


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list