Thanks for the clarification! There are many ways to do this. Page controls happen to be one of them. It is up to you how you want the application to perform rather than have the development platform dictate how it "has to be done". That's one reason Delphi is such a nice platform.
If you choose to uses multiple forms then I would edit the project source. This is how splash screens are used as well by the way. From the menu choose Projects then view source. The project source will now appear in the editor. To hide the main form but show another add Application.ShowMainForm := False; to the project source. I.E.
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.ShowMainForm := False;
Form2.Show;
Application.Run;
end.
You can easily add as many forms as you like hiding and showing them in the project source. In the above example, just add the Form1.Show statement to the menu, button or whatever you like when you want the main form (form1 here) to be seen. You can start on form 20 if you like hiding and showing them until you get to your main form. The sky is the limit! Below is an example.
Start a new project with two forms. Add a button and memo on form1. Add a button and two checkboxes on form 2.
Add this to your project source...
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.ShowMainForm := False; //This was added
Form2.Show; //This was added
Application.Run;
end.
Add application.Terminate to the Onclick event of Form1's button
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.Terminate;
end;
Add this code to the OnClick event of Form2's button...
procedure TForm2.Button1Click(Sender: TObject);
begin
if (CheckBox1.Checked = False) and (CheckBox2.Checked = False) then begin
ShowMessage('You must select a mode first!');
Exit;
end else
if (CheckBox1.Checked = True) and (CheckBox2.Checked = True) then begin
ShowMessage('Only one mode at a time please!');
Exit;
end else
if CheckBox1.Checked = True then
Form1.Memo1.Lines.Add(Edit1.Text + ' is logged in. Mode one is being used');
if CheckBox2.Checked = True then
Form1.Memo1.Lines.Add(Edit1.Text + ' is logged in. Mode two is being used');
Form1.Show;
Form2.Hide;
end;
Now you have a preliminary form that controls what happens to the main form. Those values can be from an ini file or the registry if you need to remember them for the next time.
Edited by Zorfox, 12 February 2011 - 07:01 AM.
Added example