Conditional Form Startup

I wrote a program that was originally only displayed a single form at startup, now I want to (Based on a flag that is read from the registry) display another screen at startup is desired by the user.

I need to know how to not make FORM1 show  while starting FORM2 instead.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In your Project source:
I assume Delphi 2, but technique will work with Delphi 1 too.
Also assume you have a function, 'ShouldCreateForm1' which returns a boolen.


  if ShouldCreateForm1
    then Application.CreateForm(TForm1, Form1)
    else Application.CreateForm(TForm2, Form2)


The wanted form will now be created as the applications main form.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkb2Author Commented:
I believe I misrepresented the problem. The program that I have has 7 different forms and I want to make the startup form conditional as above.

My Program contains the above CreateForms for all of the forms that are in the Program.

Now how do I do that? :)

I apologize for not be more precise?

As you've found out... The first form created will become the applications main form, and therefore show first.

You could just do something like this, assuming you've got a variable FirstForm of type integer

case FirstForm of
  1 : Application.CreateForm(TForm1, Form1);
  2 : ...

if Form1=nil then Application.CreateForm(Tform1, Form1);
if Form2=nil ....

This would create all forms, with the wanted one showing first..


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.