>>> What is the difference between
>>> Application.CreateForm(TForm1, Form1)
>>> and
>>> Form1 := TForm1.Create(Application)?
>>> Apart from the fact that the first form does not requie a var
>>> declaration?
>> actually the first one does require a var declaration. It uses
>> the same var as the second one. The Form1 in the project
>> source is the var that is defined in the forms .pas file.
>> I think the difference is that the first form created with the
>> Application.create() is made the main form for the application.
> another difference is that
> Application.CreateForm(TForm1, Form1)
> will set Form1 to nil if it's call to TForm.Create() fails while
> Form1 := TForm1.Create(Application)
> will leave the value of Form1 unchanged if Create() raises
> an exception.
That's a useful difference to be aware of. Note that an alternative is not
to specify an owner at all if the forms lifetime does not span the entire session.
with Tform1.Create(nil) do try
// Some setup
case ShowModal of
mrOK: // Some affirmative behaviour
mrCancel: // Some cancellation behaviour
end;
finally
Release;
end;
--
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