Topic: Scalable Form sizes

Hi All,
Back in October I asked about making my forms resize themselves to fit various computer screens.  I received quite a bit of feedback but was never able to make anything work for me.
-
Here's where I am today (Dec 2020):
I have 2 computers as follows:
My development laptop PC(1) - 1920 x 1080, scale 150%, Landscape
My 2nd older PC(2) -                 1366 x 768, scale 125%, Landscape
-
When I designed my forms to fit nicely on PC1 everything looks good.
However when I move my program to PC2 the forms are too big and parts of the forms go beyond the screen making the application unusable.
-
So I sized my forms to 1075 x 480 so they will work on PC2. They also work on PC1 but they don't fill up the screen.  And I assume on a bigger monitor that the forms will be the same size, however not taking advantage of the bigger screen size. Note: when I hit Maximize it does fill the screen but the form(s) remain the same size and do not scale.
-
I also noticed today that when my program is on PC2, the table grids do not show all of my entries.  It does show a horizontal scroll bar that will let me scroll right and read all the entries.  However there are no scroll bars on PC1 and that's OK as everything shows up as I originally designed them.
-
In October I received a reply from CDB as follows:
I have read that the  Delphi 'scale by' function works better if percentage scaling is used.

You could try - finding the users screen size as shown in the code snippets above and then using the scale by function increase or decrease the form size. Using your screen resolution as the default screen size.


So you would create two constants that hold your screen size - defaultScreenWidth and defaultScreenHeight and then use those to find the difference as presented by  - screen.width and screen.height (these will always be the users screen size figures).  From the result you can use the percentage figure ScaleBy(Screen.Width,percentage).
-
This sounds like it might work but I can't figure out how to implement it.  I'm not sure how or where to use the ScaleBy function.
-
Since a program could potentially be used on a smaller laptop all the way to a fullsize desktop monitor, I'm wondering how folks implement scaling for MVD programs?
-
Any thoughts will be appreciated.
Thanks
Frank (I forgot to mention that I'm a novice when it comes to scripting...but I'm learning) smile

Re: Scalable Form sizes

begin
for i := 0 to Screen.FormCount - 1 do
    Screen.Forms[i].ScaleBy(125, Screen.PixelsPerInch);
end.

3 (edited by derek 2020-12-20 14:48:02)

Re: Scalable Form sizes

Hi Frank Hi Sibprogsistem,
I had a different problem (but not unrelated) with users all accessing the same PC but some of them have problems with their vision. 
So I hold their scaling requirement in a table and when they log on, the scale is set accordingly.  There might be some merit in doing something like that for your app (see scaleby1 in the attachment).  This is probably the more flexible option in that it would work with both different screen resolutions and with different sizes that each user is comfortable with (although it needs to be manually set - but it's just one field).
Another option would be to (via a script), get the screen.width / screen.height of the machine your program is running on and compare it to the (hard coded screen.height / screen.width of the machine you are developing on) and calculate the appropriate scaling percentage (see scaleby2 in the attachment).  Not sure of the calculation (and I don't have multiple machines to test it out on) but it should be relatively straightforward.
If I remember back, I think the only thing that might need tweaking is the default row height of tablegrids which scaleby didn't cover.
(as always, passwords are the same as the userid's in the examples).
Derek.

Post's attachments

Attachment icon scale by.zip 1.4 mb, 302 downloads since 2020-12-20 

Re: Scalable Form sizes

Derek,
Thanks for the examples.  I've been going through them and seeing how they work.
-
But one thing is driving me crazy !! Where is the login screen in your example 2?
-
I wanted to turn it off and just play around with the screen sizes.  But I don't see where it is called or how to disable it.  I think it's those pesky aliens again, messing with me smile
-
Thanks
Frank

5 (edited by papafrankc 2020-12-21 06:10:07)

Re: Scalable Form sizes

Derek,
I was able to bypass the Aliens (lol) by pulling this code from your example and inserting it into my application:
// SCALING BEGIN
if screen.width = 1920 then vscale := 170;         
  if screen.Width = 1600 then vscale := 140;
  if screen.Width = 1440 then vscale := 125;
  if screen.Width = 1366 then vscale := 120;
  if screen.width = 800  then vscale := 71;
  for vi := 0 to Screen.FormCount - 1 do
  Screen.Forms[vi].ScaleBy(vscale,screen.pixelsperinch);

-
I then changed the screen settings on my laptop to match the widths above and tested them.
Everything looks pretty good on each of the settings.
-
I'm wondering if this is sound reasoning?  It works on my 1920 laptop and my other laptop (1366). I noticed that some computers can have up to 2560x1440.  Since I can't test for that and I don't have it in my code, I wonder what will happen when the program is put on a PC with those settings?  I'm assuming the 2560x1440 is for larger monitors?
-
I also have the text size set to 150%, it's easier on my old eyes.
-
I noticed one more thing.  The Scaleby doesn't seem to work on the width of the tablegrids.  You did mention there might be a problem in the tablegrids.  Although it looks like the user can use the horizontal scrollbar or drag the vertical bars between the headings to adjust the sizes.  So it's probably not too big a problem.
-
Changing the resolution settings on my PC sounds to me like it's a valid test.  What do you think?
-
Thanks
Frank

6 (edited by derek 2020-12-21 19:50:02)

Re: Scalable Form sizes

Hi Frank,
I think what might be best for the tablegrid row and column sizing issue is to do as per the attached.
1) Column sizing is easy enough using bestfitcolumns(bfboth) as an example.  However, this can't be put in the concluding 'begin....end' of your script so needs to be tied in to specific procedures.
2) Row sizing (including row, header and footer) can be put in the concluding 'begin.......end' but needs to be manually set so there's probably a bit of guess work involved, but once you know it, it'll be right for any application where you use scaling.
If your code doesn't have the appropriate screen width for the PC it's running on, you need to specify what action to take.  This can either be done as part of an 'if' statement or, as in the example, pre-set the global variable used to hold the 'scaleby' value, so if the program doesn't find any of the specified screen widths in your script, it will go with '100'.
One thing that isn't so great is that the standard button icons don't change proportionately;  so when I've used 'scaleby' I tend to make sure that my buttons have labels rather than icons.
Derek.

Post's attachments

Attachment icon scaleby3.zip 338.28 kb, 385 downloads since 2020-12-21 

Re: Scalable Form sizes

Bonjour, télécharger ce petit logiciel qui fait des miracles: reso.exe

Il adapte les logiciels a tout les écran disponibles.

Destiny