How can I at runtime embed a WebForm in FNCPagecontrol?

I wish to create a new page in runtime and embed a WebForm inside the page. I found the following code in the forum but it does not work. Any suggestions?

procedure TfrmMain.myBtnClick(Sender: TObject);
Page: TTMSFNCPageControlPage;
Container: TTMSFNCPageControlContainer;
vForm: TfrmPreProcessing;
Page := TMSFNCPageControl1.Pages.Add;
Container := Page.Container;
//New Form
vForm := TfrmPreProcessing.CreateNew(Container);
vForm.Parent := Container;
vForm.Align := alClient;

 TMSFNCPageControl1.ActivePageIndex := TMSFNCPageControl1.Pages.Count - 1;



This can be done by including a TWebHTMLDiv as a child of one of the pages, and then create the form based on the WebHTMLDiv as demonstrated with a WebPanel in the original demo. The modified demo that works with a TTMSFNCPageControl is attached (58.5 KB)

Can you please provide a code example in which the page and the panel are created in Runtime and not design time? Whatever we do the new window appears on the Main window instead.
Why do we need to use a TWebHTMLDiv object and not a TWebpanel (as in your original FormHosting demo)?


Hi, It doesn’t matter whether it is a TWEBHTMLDiv or a TWEBPanel. I’ll look into creating a sample for runtime creation as soon as possible.


Attached is a sample that creates a page control at runtime, adds a page and includes a TWEBPanel. Afterwards, click on the buttons to create the form, which will be embedded in the (57.0 KB)

Thanks. It works now but on my embedded form I have Pagecontrols again which does not appear correctly (not at all). But that is a different issue. Thanks for now.

Thank you for feedback!