Solved

Conditional Form Startup

Posted on 1997-03-26
3
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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