Article

From:
To:
Remy Lebeau (TeamB)
Subject:
Re: Delphi XE7 - cascading forms
Newsgroup:
embarcadero.public.delphi.firemonkey

Re: Delphi XE7 - cascading forms

Here is my code:

{code} program prjctMultiForm;
uses   System.StartUpCopy,   FMX.Forms,   FormMain in 'FormMain.pas' {Form1},   FormSecondary in 'FormSecondary.pas' {Form2},   FormTertiary in 'FormTertiary.pas' {Form3};
{$R *.res}
begin   Application.Initialize;   Application.CreateForm(TForm1, Form1);   Application.Run; end. {code} {code} unit FormMain;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ListView.Types, FMX.ListView,
  FMX.StdCtrls, FMX.Objects, FMX.Layouts, FormSecondary;

type   TForm1 = class(TForm)     Layout1: TLayout;     Line1: TLine;     Label1: TLabel;     Button1: TButton;     procedure Button1Click(Sender: TObject);   private     { Private declarations }   public     { Public declarations }     v_Form2: TForm2;   end;
var   Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject); begin   Form2 := TForm2.Create(self);   Form2.Show; end;
end. {code} {code} unit FormSecondary;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
  FMX.StdCtrls, FMX.Layouts, FormTertiary;

type   TForm2 = class(TForm)     Layout2: TLayout;     Label2: TLabel;     Button2: TButton;     Line2: TLine;     Button3: TButton;     procedure Button3Click(Sender: TObject);     procedure Button2Click(Sender: TObject);   private     { Private declarations }   public     { Public declarations }     v_Form3: TForm3;   end;
var   Form2: TForm2;
implementation
{$R *.fmx}
uses   FormMain;
procedure TForm2.Button3Click(Sender: TObject); begin   Form3 := TForm3.Create(Self);   Form3.Show; end;
procedure TForm2.Button2Click(Sender: TObject); begin   if Form1.Visible then     Form1.Show;   Self.Close; end;
end. {code} {code} unit FormTertiary;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
  FMX.StdCtrls, FMX.Layouts;

type   TForm3 = class(TForm)     Layout3: TLayout;     Label3: TLabel;     Line3: TLine;     Button3: TButton;     procedure Button3Click(Sender: TObject);   private     { Private declarations }   public     { Public declarations }   end;
var   Form3: TForm3;
implementation
{$R *.fmx}
uses   FormSecondary;
procedure TForm3.Button3Click(Sender: TObject); begin   if Form2.Visible then     Form2.Show;   Self.Close; end;
end. {code}
Prior to reading Eli M's answer, it was not working as the following statements were missing. Now that I have added these statements, apparently everything works as expected.

{code}
  if Form2.Visible then
    Form2.Show;

  if Form1.Visible then     Form1.Show; {code}
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> John wrote:
> 
> > What should I do in order for the 'back' button of the third form to
> > bring me back to the second form rather than the Main form?
> 
> Please show your actual code.
> 
> --
> Remy Lebeau (TeamB)
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Thu, 28 Mar 2024 11:41:43 UTC
Copyright © 2009-2024
HREF Tools Corp.