Heres an EasySqueezy one for someone:
>What is the difference between
>  panel:=tpanel.Create(owner);
>and
>  panel:=tpanel.Create(self);


When you're in a method a self reference is available to the instance of
the object this method belongs to... On Objects derived from TComponent
(IE all controls) have an Owner property... so the lines you gave essentially
are saying...

panel:=tpanel.Create(self.owner);
and
panel:=tpanel.Create(self);

All TComponents on being Freed also free anything they 'own' and so when
self.owner is freed the panel will be freed. If you pass NIL as the owner
EG panel:=tpanel.Create(NIL);
you will need to Free the panel yourself since it has no owner to do so...

>Normally I use self, but in this case I want to make a panel, which is like
>a modal construct, or separate from the main form, so I take it OWNER would
>be the one?


If it's created on the fly you can create and free it yourself but since it's the 
'main'
form this form lives the entire time anyway.  To move a panel from one form to another
change it's Parent property... note that Parent is different from Owner.... Owner 
denotes
a responsibility to control resource use and Parent denotes a hierarchy for input
(keystroke passing to parents for example) and output (drawing on a form).

>BTW when the proc is finished, do both instances need panel.destroy


when the proc exits you should always release any resources you are certain will not be
needed outside of the procedure but you should use the Free method not Destroy.
Although they currently have a symmetric behaviour (apart from the near worthless check
to see if the handle is nil in Free) this might change and for future reliability of 
your
code your should only call Free.

--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to