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
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.
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.
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?