title: Delphi: embed frame into panel and query the property of label inside the frame
body: <p>Using delphi XE7. I just want to load the frame into panel and then click button to query the label's caption property inside the frame during the runtime. I can't seem to get it working. Kindly please advise. Thanks.</p>
  
  <p>Panel2 in Unit1</p>
  
  <pre><code>unit Unit1;
  interface
  
  uses
  Winapi.Windows, Winapi.Messages, System.SysUtils,
  System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
  
  type
  TForm1 = class(TForm)
   Button4: TButton;
   Panel2: TPanel;
   procedure Button4Click(Sender: TObject);
   procedure FormCreate(Sender: TObject);
  
  private
      { Private declarations }
  public
      { Public declarations }
  end;
  
  var
    Form1: TForm1;
  implementation
  {$R *.dfm}
  
  uses Unit3{TFrame3};
  
   procedure TForm1.Button4Click(Sender: TObject);
   begin
     ShowMessage(Frame3.Label4.caption);
   end;
  
   procedure TForm1.FormCreate(Sender: TObject);
   begin
      Frame3.parent:=Panel2;
   end;
  end.
  </code></pre>
  
  <p>Frame3 in this unit</p>
  
  <pre><code>unit Unit3;
  interface
  
  uses
   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
   System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
   Vcl.StdCtrls;
  
  type
   TFrame3 = class(TFrame)
   Label4: TLabel;
   private
   public
      constructor Create(TheOwner: TComponent); override;
      destructor Destroy; override;
   end;
  
  var
    Frame3: TFrame3;
  
  implementation
  
  {$R *.dfm}
  
  constructor TFrame3.Create(TheOwner: TComponent);
   begin
     inherited Create(TheOwner);
   end;
  
  destructor TFrame3.Destroy;
   begin
     inherited Destroy;
   end;
  end.
  </code></pre>
  
  <p>When compiling ok, but running into error - "First chance exception at $005E098C. Exception class $C0000005 with message 'access violation at 0x005e098c: read of address 0x00000000'. Process Project1.exe (8416)"</p>