Host Form in TMSFNCPageControl / TMSFNCPageControlContainer

Hi Guys,

we are trying to host different forms within a Pagecontrol. Mainmenu is a SideBar linked buttons with TabSheets from Pagecontrol. On some Tabsheets we want to load dynamically Forms like this:

    	fRegisterForm:=TRegistrierung.CreateNew(webpanel1.ElementId, nil);
        fRegisterForm.parent:=tabRegistrierung;
        fRegisterform.Align:=alClient;
        fRegisterForm.Show();

the tRegisterForm is a tWebForm. Clicking the Button it shows on the Browser. But it is not created as Child-Element within the Tabsheet. We have tried to create it with the ElementId of a Webpanel within the Tabsheets but this also does not work. the new form is created directly in "body" as a child and not in defined Parent or ElementId.

Is this a bug or a feature? What I'm doing wrong?

To host a TWebForm in another control, this is done with creating it on a HTML element specifying its id. So, in your code, you set this to a webpanel HTML element.
The TTMSFNCPageControlContainer is based on a HTML CANVAS element and you cannot host another element on this CANVAS element.
I would suggest to put a TWebPanel or TWebHTMLSpan or something similar on the TTMSFNCPageControlContainer and then host your form on this control.

I tried to add a tWEbPanel into the Pagecontrols Tabsheet, now tried it with a tWebHtmlSpan (+ set a manual ElementId) into the TabSheet + set Span.Align:=alClient.

Now the Form gets visible but there is a problem with the Sidemenu. In normal, the Pagecontrols / Tabsheets content is moved based on the Sidemenus current size (compact or normal).

the new created form is visible but aligned left to 0, no mather if the Sidemenu is collapsed or expanded.

Where is this SideMenu? In the main form? The hosted form? Elsewhere?
How exactly can we reproduce this issue?

Sidemenu and Pagecontrol, Tabsheets etc. all in Mainform.

I cannot see how the SideMenu on the main form would be affected by a hosted form in a TTMSFNCPageControl.
If a problem persists, please try to isolate this and provide a sample source project with which we can reproduce the problem here.

We will create a small demo for you, asap we have time for this.

Hi Bruno,

I have changed your SideMenu Demo for showing the problem. run attached Demo and click the various Sidemenu elements. The last one should create the subform and its aligned left behind the Sidemenu
SideMenu.zip (5.0 KB)

Hi,

The USideMenu.pas file is missing from the zip file.

Sorry, attached the new zip
SideMenu.zip (6.4 KB)

Thank you for the updated zip file.
We are currently investigating this issue and will report back as soon as possible.

Can you please try creating your SubForm before assigning the ContentControl instead of in the WebSideMenuItem OnClick event?

procedure TForm1.WebFormCreate(Sender: TObject);
var
  it: TSideMenuItem;
begin
  //...
    if not assigned(fSubForm) then begin
    	fSubForm:=tmySubForm.CreateNew(tabSubForm.ElementID, nil);
        fSubForm.Align:=alClient;
//    	fRegisterForm.Load();
    end;
        fSubForm.Show();

  it := WebSideMenu1.Items.Add;
  it.Text := 'Subform in Tab';
  it.Enabled := true;
  it.MaterialGlyph := 'highlight_off';
  it.ContentControl := tabSubForm;
//  it.OnClick:=@OpenSubform;

//...
end;

Your workaround works, but we need to create the subforms within a Tabsheet on demand ...

Would it be possible, if we create a "placeholder" for a Sidemenu Item, later delete it and create it again after the subform has created?

... or will you provide an update for this scenario?

Thanks for your feedback.

The specific scenario you suggested has not been tested yet so I'm unable to confirm if this will work as expected for now.
Can you try to create a "placeholder" form then replace the form's content on demand?

We'll have to investigate if this behavior can be improved in a future version of TMS WEB Core.

Can you create a small example, how to replace a "placeholder" Forms content in runtime?

This was just a suggestion based on your sample project. I'm not fully familiar with the details of your entire application, so it may not be applicable in your specific case. Please consider this as a potential starting point that might need further adaptation to fit your needs.

procedure TForm1.WebFormCreate(Sender: TObject);
var
  it: TSideMenuItem;
begin

 //...

    if not assigned(fSubForm) then begin
    	fSubForm:=tmySubForm.CreateNew(tabSubForm.ElementID, nil);
        fSubForm.Align:=alClient;
//    	fRegisterForm.Load();
    end;
        fSubForm.Show();

  it := WebSideMenu1.Items.Add;
  it.Text := 'Subform in Tab';
  it.Enabled := true;
  it.MaterialGlyph := 'highlight_off';
  it.ContentControl := tabSubForm;
  it.OnClick:=@OpenSubform;

//...
end;

procedure TForm1.OpenSubform(Sender:tObject);
var
  p: TWebPanel;
begin
  p := TWebPanel(fSubForm.FindComponent('WebPanel1'));
  if Assigned(p) then
  begin
    p.Caption := 'updated';
  end;
end;