Recent

Author Topic: Form scaling  (Read 1040 times)

fxeconomist

  • New Member
  • *
  • Posts: 48
Form scaling
« on: April 16, 2024, 06:11:14 pm »
Hi,

I noticed that as I worked on my project in CodeTyphon at home on my FullHD monitor, there was practically no change when I moved the project on my other computer with UHD resolution.

However, after I migrated the project to Lazarus, I noticed the form Width and Height are in pixels, and the form did not scale.
Is there any property to restore this scaling feature ?

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Form scaling
« Reply #1 on: April 16, 2024, 06:22:43 pm »
I don't know how CodeTyphon handles form scaling. Maybe it is not compatible to the way Lazarus does it. Is the box "Use LCL Scaling" checked after opening the project in Lazarus? In Windows, you should also make sure that "Use manifest resource" is checked and one of the "on" options in the "DPI awareness" combobox is selected.

But in general: I don't think that it is a good idea to switch between Codetyphon and Lazarus. Either use CodeTyphon, then stay with it. Or use Lazarus, then stay with it, too.

fxeconomist

  • New Member
  • *
  • Posts: 48
Re: Form scaling
« Reply #2 on: April 16, 2024, 06:48:40 pm »
I don't think I have any reason to switch back. I actually used CodeTyphon because I found Lazarus documentation installed there easily.
Least on my first install, context-sensitive help worked immediately.

I migrated the project to Lazarus because there is just more stuff available, the kind of stuff I would need, like compiling for Android and 3d engines.

All options are set, including the Scaled property of the form.

But it doesn't make any sense. If the Width property is in pixels, or in pixels relative to current UHD resolution, then hardcoding a Wdith/Height inside is a bad thing, right ? Cause these numbers would be really hardcoded to the UHD resolution and wouldn't change.

The thing is in CodeTyphon the Form Designer has navigation bars on the form, so I can make the form larger while its window remains smaller. When the application starts, the form is created at its full size.

In Lazarus the Form Designer doesn't have navigation bars on the form, if I want the full form I have to keep it at full size while designing it.

This became hard, so I thought I can make the form smaller in designer and then readjust it in the .Paint method. But it's resolution hardcoded, so that will cause problems in case I want to compile for another target...
« Last Edit: April 16, 2024, 07:03:22 pm by fxeconomist »

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Form scaling
« Reply #3 on: April 16, 2024, 07:38:50 pm »
But it doesn't make any sense. If the Width property is in pixels, or in pixels relative to current UHD resolution, then hardcoding a Wdith/Height inside is a bad thing, right ? Cause these numbers would be really hardcoded to the UHD resolution and wouldn't change.
LCLScaling will make them change since the form stores the PixelsPerInch at which the form was designed. Knowing this all dimensions are adjusted automatically when the resolution changes.

In the Lazarus options ("Environment" > "Form Editor") there is a checkbox "Enforce DPI Scaling at designtime". This should be checked.

The thing is in CodeTyphon the Form Designer has navigation bars on the form, so I can make the form larger while its window remains smaller. When the application starts, the form is created at its full size.
Yes, that's the form editor. You can do this in Lazarus, too, when you install the DockedFormEditor package. I don't use it, so I can't tell which effect it has on LCLScaling.

fxeconomist

  • New Member
  • *
  • Posts: 48
Re: Form scaling
« Reply #4 on: April 16, 2024, 08:09:39 pm »
But it doesn't make any sense. If the Width property is in pixels, or in pixels relative to current UHD resolution, then hardcoding a Wdith/Height inside is a bad thing, right ? Cause these numbers would be really hardcoded to the UHD resolution and wouldn't change.
LCLScaling will make them change since the form stores the PixelsPerInch at which the form was designed. Knowing this all dimensions are adjusted automatically when the resolution changes.

In the Lazarus options ("Environment" > "Form Editor") there is a checkbox "Enforce DPI Scaling at designtime". This should be checked.

The thing is in CodeTyphon the Form Designer has navigation bars on the form, so I can make the form larger while its window remains smaller. When the application starts, the form is created at its full size.
Yes, that's the form editor. You can do this in Lazarus, too, when you install the DockedFormEditor package. I don't use it, so I can't tell which effect it has on LCLScaling.

Thanks for the tips!

Well, the LCL Scaling was there, and I went forward with the DockedFormEditor. It restored the familiar behaviour from CodeTyphon.
Then I tested it again. Went fullhd. Lazarus IDE messed up, but ran the app, and surprisingly, it was good on fullhd. Then went back to UHD and restored desktop!

 

TinyPortal © 2005-2018