Dynamic setting of main form

<< Click to Display Table of Contents >>

Navigation:  Forum >

Dynamic setting of main form

Forum link

 


 

03-09-2020, 10:07 PM:

 

Hello,

 

I've read the section in "Migrating to IntraWeb XIV and XV" regarding "Dynamically setting the application main form".

 

I have a Standalone application that accesses a lot of variables defined in the usersessionUnit. The main form sees these variables by including the UsersessionUnit and the ServerController unit in it's uses section.

 

The suggested way to do it requires the inclusion of the form's unit in the uses clause of the ServerController Unit.

 

I would like to dynamically switch the MainForm out for another more suited for display on a mobile device when required. 

 

If I try to do it as shown in the documentation above, the inclusion of the form's unit in the ServerController's uses clause creates a circular reference.

 

It leads me to believe that maybe I'm utilizing the usersessionunit incorrectly.

 

How can I accomplish dynamically swapping the MainForm while still isolating each user's session variables?

 

Thanks in advance,

 

Kevin

 


 

03-10-2020, 09:14 AM:

 

Hi Kevin,

 

try the following:

 

implementation {of TIWServerControllerBase}

 

uses

 

MyMobileForm, MyStandardForm;

 

and

 

procedure TApplServer.IWServerControllerBaseNewSession(ASession: TIWApplication);

 

begin

 

ASession.Data:=TApplSession.Create(nil, ASession);

 

if ASession.Browser.IsMobile then TMyMobileForm.SetAsMainForm else TMyStandardForm.SetAsMainForm;

 

end;

 

Regards

 

Lorbass

 


 

03-10-2020, 03:59 PM:

 

(03-10-2020, 09:14 AM)Lorbass Wrote: [ -> ]Hi Kevin,

 

try the following:

 

implementation {of TIWServerControllerBase}

 

uses

 

  MyMobileForm, MyStandardForm;

 

and

 

procedure TApplServer.IWServerControllerBaseNewSession(ASession: TIWApplication);

 

begin

 

  ASession.Data:=TApplSession.Create(nil, ASession);

 

  if ASession.Browser.IsMobile then TMyMobileForm.SetAsMainForm else TMyStandardForm.SetAsMainForm;

 

end;

 

Regards

 

Lorbass

 

Thank you Lorbass!