Chrissy

Just a few basics

1/ In Delphi you almost never have to use pointers and new() is really for
non-object use
2/ A TComponent derived class can own other TComponents  (which may own
other...) See TComponent.Components array &  TComponent.ComponentCount
(simarly TWinControl implement Controls array and ControlCount)
3/ By default a 'Form' (a TComponent Derivative) owns all the components on
it
4/ The 'owner' is passed to the constuctor if the 'owner' is nil then
something has to destroy it
This is because the TComponent constructor 'registers' itself with the owner
(who maintains a list of it components)
so that it knows who to destroy (in its destructor).
5/ It is imperitive to understand the difference between Parent and Owner
6/ It is imperitive to understand the difference between
TObject/TPersistent/TComponent

I think in various versions of Delphi the overhead of components traversing
lists and registering a list of components (and the
sequencing of destuction) was annoying so it became fashionable to
programmatically create components with a nil Owner
and Destroy them yourself however in my experience it is better to go throuh
the pain of passing an owner and working though
the consequences (esp with visible components because there is invariably a
link between ownership and parenthood) than
continue the 'trick'

Simple Aint it
HTH

Regards Neven
N.K. MacEwan B.E. E&E
Ph 649 574 0027
Fax 649 570 2706

"A truth denied the light of action will wither to a promise, propaganda and
then a lie"

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to