Solved

Conditional Form Startup

Posted on 1997-03-26
3
202 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

12 Experts available now in Live!

Get 1:1 Help Now