title: Determine which form in activepage, delphi
body: <p>I have a mainform (frmMain) with a pagecontrol. The pagecontrol is populated at startup by several forms, let us say Form1, Form2, and Form3</p>
  
  <pre><code>procedure TForm1.FormCreate(Sender: TObject);
  begin
     ManualDock(frmMain.PageControl1);
     show;
  end;
  procedure TForm2.FormCreate(Sender: TObject);
  begin
     ManualDock(frmMain.PageControl1);
     show;
  end;
  procedure TForm3.FormCreate(Sender: TObject);
  begin
     ManualDock(frmMain.PageControl1);
     show;
  end;
  </code></pre>
  
  <p>That works great.
  When I then change activepage, I want the OnActivate method called on the form corresponding to the activepage, so I tried this;</p>
  
  <pre><code>procedure TfrmMain.PageControl1Change(Sender: TObject);
  begin
    with pagecontrol1 do
    begin
       lbHeading.Caption := activepage.Caption;
       with tform(activepage) do        // &lt;= This does 
       if assigned(onactivate) then     // &lt;= not
       onactivate(self);                // &lt;= work
    end;
  end;
  </code></pre>
  
  <p>Activepage is of type TTabsheet</p>