Screen Orientation

How do I know if the screen is in Portrait or Landscape?

And how do you know when it was turned?

You could use something like


Bruno Fierens2019-04-25 00:09:37
That part, looking at the sources I have already discovered.

The biggest problem is that the OnResize event only fires in the main form. The rest is not working.

I'm using the latest beta. Could it be that?

Are you  using hosted child forms or in what exact scenario is OnResize not triggered?

I have similar issue in application with login form + other forms construction similar to XDataMusicWeb.

WebFormResize does not fire to login form or main form. 
In simple application if I just CreateForm and run application then WebFormResize works fine.

I tried to add TFViewLogin.WebFormResize to XDataMusicWeb demo also and it is not fired.


I have the following Code.

procedure TForm7.changeLayout (size : String) ;

begin
    if size = 'small' then begin
      gridPanelStory.ColumnCollection.Items[0].Value := 99;
      gridPanelStory.ColumnCollection.Items[1].Value := 1;
      gridPanelStory.ControlCollection.Items[0].Control := HTMLContStory ;
      gridPanelStory.ControlCollection.Items[1].Control := webButton4;
      gridPanelStory.ControlCollection.Items[2].Control := respGridPanelEnquiry ;
      gridPanelStory.ControlCollection.Items[3].Control := webButton3;
      gridPanelStory.ControlCollection.Items[4].Control := multimediaPlayerStory;

    end;

    if size = 'medium' then begin


    end;

    if size = 'large' then begin
      gridPanelStory.ColumnCollection.Items[0].Value := 70;
      gridPanelStory.ColumnCollection.Items[1].Value := 30;
      gridPanelStory.ControlCollection.Items[0].Control := HTMLContStory ;
      gridPanelStory.ControlCollection.Items[1].Control := respGridPanelEnquiry;
      gridPanelStory.ControlCollection.Items[2].Control := multimediaPlayerStory ;
      gridPanelStory.ControlCollection.Items[3].Control := webButton3;
      gridPanelStory.ControlCollection.Items[4].Control := webButton4;

    end;
end;
procedure TForm7.WebFormCreate(Sender: TObject);

begin

       Application.InsertCSS('themecss','fresca/myTheme.css');
       screenWidth := ClientWidth;
       if screenWidth < 800 then  changeLayout('small');
       if screenWidth > 800 then  changeLayout('large');



      end;
procedure TForm7.WebFormResize(Sender: TObject);
begin
        labelWidth.Caption := clientWidth.ToString;
        if clientWidth < 800 then changeLayout('small');
        if clientWidth > 800 then changeLayout('large');

end;

However on iPhone 12 Pro Max when rotating the device WebFormResize event shows
Portrait labelWidth.Caption := clientWidth.ToString; = 428.
Landscape labelWidth.Caption := clientWidth.ToString; = 832
but the changeLayout is not firing.

Sorry web link TMS Web Project

I do not understand.
You mention 'changeLayout' is not firing, but in your code I see you call changeLayout yourself from form.OnResize and you say form.OnResize is triggered?