Recent

Author Topic: Coping with multiple video resolutions.  (Read 1189 times)

Yukiko

  • Jr. Member
  • **
  • Posts: 55
Coping with multiple video resolutions.
« on: November 19, 2020, 05:45:54 am »
I have written a program using Lazarus that provides a GUI interface to aid in configuring a multiplayer game emulator. I have run into an issue. I wrote the program on my system which has a video resolution of 1920 x 1080. However, when the program is run on lower resolution displays, eg. 1366x768, the user does not have access to the entire GUI interface despite the fact that I have scroll bars in the main form.
 I am using the standard controls, buttons, etc. that ship with Lazarus. Lazarus version is 2.0.10 r63526. My system is Windows 10 version 20-04.

If anyone can help me, I would appreciate it. I can provide a screen-shot if necessary.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Coping with multiple video resolutions.
« Reply #1 on: November 19, 2020, 07:12:22 am »
See the Autosize / Layout Wiki article.

Yukiko

  • Jr. Member
  • **
  • Posts: 55
Re: Coping with multiple video resolutions.
« Reply #2 on: November 19, 2020, 09:10:34 am »
Thanks for the quick reply. It appears that just setting
Code: Pascal  [Select][+][-]
  1. Form1.AutoSize := 1
for my main form does not fix the issue. I am thinking that either I need to set all controls to AutoSize or I will need to do a complete redesign of my program to be compatible with smaller displays.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Coping with multiple video resolutions.
« Reply #3 on: November 19, 2020, 09:17:48 am »
Did you also make sure that you correctly set anchors and child sizing properties? Read the linked article in full and play around with the suggestions there. The LCL's auto layouting is very powerful, but needs to be used correctly.

Yukiko

  • Jr. Member
  • **
  • Posts: 55
Re: Coping with multiple video resolutions.
« Reply #4 on: November 19, 2020, 09:21:00 am »
Ok. I will. Maybe I better read it once I've had a good night's sleep. :)
Thank you.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Coping with multiple video resolutions.
« Reply #5 on: November 19, 2020, 02:23:48 pm »
Thanks for the quick reply. It appears that just setting
Code: Pascal  [Select][+][-]
  1. Form1.AutoSize := 1
for my main form does not fix the issue.

Setting the form's Autosize to True makes the form size itself so that all its contained controls are "shown", which in your case seems to be as in the higher resolution screen. Instead, you should set it to False to allow you to change its size to the current screen and setting AutoScroll to True, if apropriate.

Note, though, that AutoScroll is only valid if the form's BorderStyle is any of the sizeable ones: bsSizeable or bsSizeToolWin. Otherwise it won't do what you expect.

Taking all into account I would suggest the same as those above: read  the AutoSize/Layout article (and related ones) in the wiki to learn how to adapt both the form and its contents to different screens.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Yukiko

  • Jr. Member
  • **
  • Posts: 55
Re: Coping with multiple video resolutions.
« Reply #6 on: December 04, 2020, 08:19:20 am »
Thanks lucamar. What I was hoping to achieve was to have vertical and horizontal scroll bars to allow scrolling within the program's main form to allow access to the controls hidden from view due to the reduced resolution. A couple of years ago I had a user with a 720p display and, at that time, I added the scroll bars and tested it on a 720p TV display I had at the time. It did what I had intended back then. So I suspect something must have changed, either in the Windows display handler (or whatever it is called) or maybe in Lazarus. I do not see the scroll bars when accessing my program remotely and neither does the user who tried to run it on his notebook.

I wasn't looking to have the controls resize based on the display resolution. If that's what I need to do then I guess I'll do it but that process seems to be pretty involved.

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Coping with multiple video resolutions.
« Reply #7 on: December 04, 2020, 10:49:17 am »
When your 1920x1080 monitor runs at 96ppi (100% font size) you simply should never design forms larger than the smallest resolution of your users, usually 1024x768. When your designtime pixels per inch are larger the max form size can be larger by the percentage to 96ppi, if LCL scaling is active (which will scale the size back to user ppi).

When your application is supposed to run on full screen make ample use of the auto-sizing and auto-layout features provided by the IDE as the others already noted.

A typical issue is that with two monitors. Here the form is often designed on the second monitor, and thus the form has a Left position outside the monitor of single-monitor systems. Always make sure that your application contains code to
reposition the form.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Coping with multiple video resolutions.
« Reply #8 on: December 04, 2020, 12:29:14 pm »
I do not see the scroll bars when accessing my program remotely and neither does the user who tried to run it on his notebook.

Hmmm ... Just did a small test here (Linux-gtk2) and it works: when AutoScroll is set to True the scroll bars show when there controls outside the visible part of the form. Here's the code I used to test:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   i: Integer;
  4. begin
  5.   for i := 1 to 5 do
  6.     with TPanel.Create(Self) do begin
  7.       Caption := 'Panel ' + i.ToString;
  8.       Align := alLeft;
  9.       Parent := Self;
  10.     end;
  11. end;

One thing of note is that it failed in the first run but as soon as I started to write this post it startted working :o
I noticed that after setting AutoScroll to True in the Object Inspector the Page value of both bars is changed to 1. Maybe you should check them and see what their value is (and also to make sure their Visible property is set to True).

As a workaround, if it still doesn't work, you might set HorzScrollBar.Visible to True (and same for VertScrollBar) in code, say, in an OnCreate handler. And maybe you should add a bug report, though given the result of this test it might be widgetset-dependent.

HTH
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018