Nesler, Thomas J wrote: > I have always created forms using the Form.Create(Self); method but I am > reading in Marco Cantus book that there is another way: > Form.Create(Application); > > What is the difference and is there a best practise I should use?
The difference is in what object owns the form. You can also specify nil as the owner, if you don't need the object to be owned by anything. > procedure TForm1.Button1Click(Sender: TObject); > Var > Form2: TForm2; > begin > Form2:= TForm2.Create(Self); > Form2.Show; > end; With that way, Form2 will get destroyed automatically when you free the owning instance of TForm1. > Here is the alternate method as I understand it: > > procedure TForm1.Button1Click(Sender: TObject); > Var > Form2: TForm2; > begin > Form2:= TForm2.Create(Self); > Form2.Show; > end; That way is the same. Did you mean this? Form2 := TForm2.Create(Application); With that way, Form2 will get destroyed when the application object gets destroyed. A component destroys all the components it owns before it destroys itself. -- Rob ------------------------ Yahoo! Groups Sponsor --------------------~--> <font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12hemmqnf/M=362329.6886308.7839368.1510227/D=groups/S=1705115362:TM/Y=YAHOO/EXP=1124841925/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992 ">Fair play? Video games influencing politics. Click and talk back!</a>.</font> --------------------------------------------------------------------~-> ----------------------------------------------------- Home page: http://groups.yahoo.com/group/delphi-en/ To unsubscribe: [EMAIL PROTECTED] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/delphi-en/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

