Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic setting of main form
#1
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
Reply
#2
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
The way to success is always under construction ... but i see a light at the end of the tunnel  Idea Big Grin
Reply
#3
(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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)