Hi,
I've a really strange problem.
I'm trying to include two WebForms in a HTML Template.
If I add only the first it works fine.
If I add only the second if works fine, too.
But when I try to add the first and then, in the next source code line my second WebForm,
then the program flow (watched in my debugger) is really strange.
Here is the code:
unit App.MainPage;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, WEBLib.ExtCtrls, WEBLib.WebCtrls,
WEBLib.StdCtrls, Vcl.Controls, Vcl.StdCtrls,
Page.MenuSetup.RESTServer,
Page.MenuSetup.UserInfo;
type
TMainPage = class(TWebForm)
procedure MainPageCreate(Sender: TObject);
private
{ Private-Deklarationen }
FPageMenuSetupRESTServer: TPageMenuSetupRESTServer;
FPageMenuSetupUserInfo: TPageMenuSetupUserInfo;
procedure CreateSubForm1;
procedure CreateSubForm2;
public
{ Public-Deklarationen }
end;
var
MainPage: TMainPage;
implementation
{$R *.dfm}
procedure TMainPage.CreateSubForm1;
procedure AfterCreate1(AForm: TObject);
begin
if not Assigned(AForm) then exit;
// Handler für PageMenuSetupRESTServer -------------------------------------
if AForm is TPageMenuSetupRESTServer then
FPageMenuSetupRESTServer.Initialize;
end;
begin
FPageMenuSetupRESTServer :=
TPageMenuSetupRESTServer.CreateNew('id_page_menu_setup_restserver_content',
@AfterCreate1);
end;
procedure TMainPage.CreateSubForm2;
procedure AfterCreate2(AForm: TObject);
begin
if not Assigned(AForm) then exit;
// Handler für PageMenuSetupUserInfo ---------------------------------------
if AForm is TPageMenuSetupUserInfo then
FPageMenuSetupUserInfo.Initialize;
end;
begin
FPageMenuSetupUserInfo :=
TPageMenuSetupUserInfo.CreateNew('id_page_menu_setup_userinfo_content',
@AfterCreate2);
end;
procedure TMainPage.MainPageCreate(Sender: TObject);
begin
CreateSubForm1;
CreateSubForm2;
end;
end.
When I run this code the code flow is the following (see picture for line-numbers)
It starts in line 75 (CreateSubForm1),
then line 49 ( TPageMenuSetupRESTServer.CreateNew),
now I thought it should be continued with line 41 (AfterCreate1), but no,
it continues with line 76 (CreateSubForm2),
then line 67 (TPageMenuSetupUserInfo.CreateNew),
then line 59,62,63 (AfterCreate2)
Why AfterCreate1 is not called?
Is there a way to achieve the needed sequence?
I have tried to us async/await but I can't find an implementation to create embedded forms that way.
Any help is really appreciated.
Thanks for your support
Gerhard