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);
var
Page: TTMSFNCPageControlPage;
Container: TTMSFNCPageControlContainer;
vForm: TfrmPreProcessing;
begin
Page := TMSFNCPageControl1.Pages.Add;
Container := Page.Container;
//New Form
vForm := TfrmPreProcessing.CreateNew(Container);
vForm.Parent := Container;
vForm.Align := alClient;
vForm.Show;

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

end;
//-------------------------------------------------------------------

BR
Amin

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

TMSWeb_FormHosting.zip (58.5 KB)

Hi
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)?

BR
Amin

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.

Hi,

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 panel.TMSWeb_FormHosting_Dynamic_PageControl.zip (57.0 KB)

Hi
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.
BR
Amin

Thank you for feedback!