Theres a basic one.
The App.CreateForm is a application´s method and all forms created with this
are owned by app. But if you need for example just create a form with no
owner like Create(Self) you have to use the form´s create.
Another behavior that I finded out is if you use the app.createform and you
create 2 instances of the same form, the app create for the second one just
a pointer for the first and if you destroy for example the second one, the
first is destroyed too. I may cause exception in your app.
I´m not sure if I was clear but I try!!
Alexandre Eduardo BR
Howard Moon escreveu na mensagem <8l42ek$ji...@bornews.borland.com>...
The latter sets the MainForm attribute for the first form created. There is
never a need to use it outside the DPR file.
Mike Orriss (TeamB & Developer Express)
(Unless stated otherwise, my replies relate to Delphi 5)
(No unsolicited e-mail replies please)
Application.CreateForm will also make the form created the
applicaiton's main form if a main form does not already exist.
I use TForm.Create when I'm creating forms myself, and let Delphi use
Application.CreateForm for autocreated forms, which, in my apps, are the
main form only.
-Craig
--
Craig Stuntz Vertex Systems Corporation
Senior Developer http://www.vertexsoftware.com
Form1 := TForm1.Create(Application);
will crash if you for instance refer to variable Form1 in the forms
OnCreate method,
Application.CreateForm(TForm1, Form1)
will not crash in such a case. However, you shouldn't need to refer to
the global declaration Form1, so if your code is well written (the way
I see it) use Form1 := TForm1.Create(Application {or watever owner you
want}) instead.
//Jonas
In article <8l42ek$ji...@bornews.borland.com>,
"Howard Moon" <hm...@landstar.com> wrote:
> Hi...
> just out of curiosity, what's the difference between calling
TForm.Create
> and Application.CreateForm? The project file obviously uses
CreateForm for
> auto-created forms, but we've been using TMyForm.Create to launch
forms of
> our own from code. Even the Help example of CreateForm includes the
line
> "with TForm5.Create(nil) do". When should we use FormCreate instead
of
> TMyForm.Create (if ever)?
> -Howard
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
John Pierce
Craig Stuntz escreveu na mensagem
<3975B681.8F8987B@no_spam.vertexsoftware.com>...
Only if you show the form non-modally. For modal forms you typically
create, showmodal, and free them all in one sequence.
-Mike
None if you're just using the modal result. However, I typically create the
form, populate it with data, show it modally, do something with the edited
data, and then free the form.
-Mike
During runtime created forms should IMHO always contain a caFree in
their OnClose method.
Alex
--
*** http://www.bullterrier-in-not.de/massenmord.htm ***
Author of the free Chatsystem PINO! || Website: http://www.alcomp.net
Available at http://pino.cjb.net || Chat : pinochat.dhs.org:8080
But where should be the advantage of this solution?
Alex
OK, for such a usage you have to free it manually. Normally I just think
its better to centralize the code.
It's a good practice to free memory in the same place it was allocated,
whenever possible.