Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
start the application with a differente presentation depending on the device model
Hello how to make the application have a different presentation depending on whether it is launched on a smarphone or an I-phone and on a PC.

In one case it would be in portrait mode and in the other, in landscape mode.

I think you need to run a JavaScript at startup, but how to get the result of the javascript function to tell Intraweb to use a portrait or landscape template.

You can look at the resolution of the device or the browser string and adjust as necessary. You can then change which template is uses, which page is used, adjust the layout, or even use JS in the template to make these changes.

Or more easily use a responsive layout using a template. An easy way to do this is to use Bootstrap templates which IntraWeb also supports.
You can use ServerController.OnGetMainForm event.

This event triggers just before rendering the first form for that session. The session has already been created and you have all information for it:

procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
  WebApp: TIWApplication;
  w, h: Integer;
  isMobile: Boolean;
  WebApp := gGetWebApplicationThreadVar;
  if Assigned(WebApp) then
    w := WebApp.FormWidth;
    h := WebApp.FormHeight;
    isMobile := WebApp.Browser.IsMobile;

Then, based on this information you can set vMainForm variable to the specific form to handle that client.
hello it is ok , thank you very much

Forum Jump:

Users browsing this thread: 1 Guest(s)