?
Solved

Conditional Form Startup

Posted on 1997-03-26
3
Medium Priority
?
224 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 150 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 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