TMSFNCPageControl

Is possible to embed a form in pagecontrol like a TDI application?
if possible, how to do it? will events work normally?
have samples?

Hi,


It depends on the framework you want to use, but technically it should be possible.the pagecontrol uses panels, inheriting from TCustomControl, so you can embed other controls inside, and the MDI technique that is being used in VCL for example also allows embedding a form in a control.

I'm trying to create a way to dynamically add forms to pagecontrol.

But as soon as I add it, the form is not displayed.
What can I be doing wrong?
my code:

var
  Page: TTMSFNCPageControlPage;
  Container: TTMSFNCPageControlContainer;
  vForm: TForm1;
begin
   // New Page
  Page := pgc.Pages.Add;

  // Create Container Owner
  // Params: AOwner = PageControl / Page = Page;
  Container := TTMSFNCPageControlContainer.Create(pgc, Page);
  Container.PageControl := pgc;

  //New Form
  vForm := TForm1.Create(Container);
  vForm.Parent := Container;
  vForm.Align := alClient;
  vForm.Show;

  //Set Caption for Page
  Page.Text:= vForm.Caption;
  // Active Page in PageControl
  pgc.ActivePageIndex := pgc.Pages.Count - 1;

Hi, please use the following code:




var
  Page: TTMSFNCPageControlPage;
  Container: TTMSFNCPageControlContainer;
  vForm: TForm;
begin
  TMSFNCPageControl1.Pages.Clear;
  Page := TMSFNCPageControl1.Pages.Add;


  Container := Page.Container;


  //New Form
  vForm := TForm.CreateNew(Container);
  vForm.Parent := Container;
  vForm.Align := alClient;
  vForm.Show;


  //Set Caption for Page
  Page.Text:= vForm.Caption;
  // Active Page in PageControl
  TMSFNCPageControl1.ActivePageIndex := TMSFNCPageControl1.Pages.Count - 1;
end;

Thanks, it worked!

i just replace this line vForm := TForm.CreateNew(Container) for this vForm := TForm.Create(Container) and it worked as i expected.

Thanks