title: How can I display a Delphi form in a panel?
body: <p>I've tried to follow the example of <a href="http://docwiki.embarcadero.com/CodeExamples/XE7/en/FMXEmbeddedForm_(Delphi)" rel="nofollow">http://docwiki.embarcadero.com/CodeExamples/XE7/en/FMXEmbeddedForm_(Delphi)</a> but I hit my first problem with the children of TCustomForm, which are apparently read only, so I commented that out and put in <code>ArgForm.Parent:= ArgParent;</code> instead, but I still just get an empty screen and can't see the buttons that are in my second form.</p>
  
  <p>The code for my main form is:</p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
    FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, Unit2;
  
  type
    TForm1 = class(TForm)
      Panel1: TPanel;
      procedure FormCreate(Sender: TObject);
      procedure EmbedForm(ArgParent : TControl; ArgForm : TCustomForm);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form1: TForm1;
    Form2: TForm2;
  
  implementation
  
  {$R *.fmx}
  
  procedure TForm1.FormCreate(Sender: TObject);
  begin
    Form2:= TForm2.Create(Self);
    EmbedForm(Panel1, Form2);
  end;
  
  procedure TForm1.EmbedForm(ArgParent: TControl; ArgForm: TCustomForm);
  begin
    //while ArgForm.ChildrenCount&gt;0 do
    //begin
      //ArgForm.Children[0]:= ArgParent);
    //end;
    ArgForm.Parent:= ArgParent;
  end;
  end.
  </code></pre>
  
  <p>The code for the form to put in the panel of my main form is:</p>
  
  <pre><code>unit Unit2;
  
  interface
  
  uses
    System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
    FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls;
  
  type
    TForm2 = class(TForm)
      Button1: TButton;
      Button2: TButton;
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form2: TForm2;
  
  implementation
  
  {$R *.fmx}
  
  end.
  </code></pre>