Solved

Conditional Form Startup

Posted on 1997-03-26
3
209 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:jkb2
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
sperling earned 50 total points
ID: 1335008
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.


begin
  Application.Initialize;  

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

  Application.Run;
end.


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

Regards,

Erik.
0
 
LVL 1

Author Comment

by:jkb2
ID: 1335009
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?


0
 
LVL 3

Expert Comment

by:sperling
ID: 1335010
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 : ...
  .
  .
end;

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

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

Regards,

Erik.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now