Bryan Smith mentioned this to Gary Weinfurther:
BS> Hi, Gary. If, by that, you mean that we should get rid of the
BS> Application.CreateForm(
BS> code that Delphi automatically places in the .DPR file, I wish you would
BS> expand your line of thought so that we can see why you suggest that.
I do mean that, although indirectly. If you display the Project Options, the
Forms tab is used to designate which forms are autocreated. This is the
proper way to change the autocreation of your forms. If you remove a form
from the autocreate list, Delphi will automatically remove its "CreateForm"
line from the DPR file.
In most cases, only the main form should be autocreated. Here's why:
1. Creating every form at application startup makes your application take a
lot longer to start.
2. All those forms are taking up memory and Windows resources, whether or not
the user is using and/or seeing them.
3. You can create multiple instances of a form by explicitly creating them.
Here's one way to create and show a form at runtime:
with TMyForm.Create(Self) do
try
ShowModal;
finally
Free;
end;
Note that this example does not assign the form object to the global form
variable. If you need to use the global form variable to reference the form,
then you can do it like this:
MyForm := TMyForm.Create(Self);
with MyForm do
try
ShowModal;
finally
Free;
MyForm := nil;
end;
...Gary
--- GoldED 2.41
---------------
* Origin: Nobody expects the Flying Circus BBS! (1:2410/905)
|