// Add the following code to the unit where the TParentForm class is defined. // Add the following method to the TParentForm class. // AParent can be any control, such as a panel or a tabsheet item of a TabControl.
type TForm1 = class(TForm) Button1: TButton; Panel1: TPanel; Layout1: TLayout; procedure Button1Click(Sender: TObject); private procedure EmbeddForm(AParent: TControl; AForm: TCustomForm); public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.fmx}
uses Unit2;
procedure TParentForm.EmbeddForm(AParent:TControl; AForm:TCustomForm); begin while AForm.ChildrenCount>0 do AForm.Children[0].Parent:=AParent; end; Add the following code to the OnCreate event handler of the ParentForm.
procedure TParentForm.FormCreate(Sender: TObject); begin EmbeddForm(Panel1, TFormXXXXXXXXXX.Create(Self)); end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
//公共函数 procedure TFrmMain.OpenForm(AParent: TControl; AForm: TCustomForm); begin while AForm.ChildrenCount>0 do AForm.Children[0].Parent:=AParent; end;
//主窗体 procedure TFrmMain.FormCreate(Sender: TObject); begin FrmMain.OpenForm(FrmMain.Panel2, TFrmWorkTask.Create(Self)); end;
打开子窗体 procedure TFrmMain.ListBoxItem1Click(Sender: TObject); begin FrmWorkTask.Show; end;
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
procedure TFrmMain.ListBoxItem1Click(Sender: TObject); begin OpenForm(Panel2,FrmWorkTask); end;
procedure TFrmMain.OpenForm(AParent: TControl; AForm: TCustomForm); begin while AForm.ChildrenCount>0 do AForm.Children[0].Parent:=AParent; end;
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
in fact, you cannot use ".SHOW", because your "form" will be showed into "Panel", not on the screen!
on Embarcadero sample, in fact, you are just "copy" all "children" object from "formXXX" to "Panel1".
in FMX, it will be better if you use a "Layout" technic.
1) Form1-main has a "TLayout"-Main (to receive all object from others forms)
2) Form2-clients has a "TLayout"-Client with all objects Form3-clients has a "TLayout"-Client with all objects etc...
3) then, you can copy all objects from Layout-clients to Layout-Main
Form1.LayoutAAA.DeleteChildren; // delete old objects Form1.LayoutAAA.AddObject( Form2.LayoutBBB ); // add new objects
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3