Recent

Author Topic: Strange behaviour of TCheckBox and Windows Menu settings  (Read 5340 times)

Tharon

  • Jr. Member
  • **
  • Posts: 61
Strange behaviour of TCheckBox and Windows Menu settings
« on: September 22, 2021, 06:02:43 pm »
Hello, i've encountered a strange issue with check boxes and the font size setting of Windows.

I have recentely purchased a 1440p monitor, so i've changed various font size of windows to be more readable. To my suprise, if i change the font size for the menu setting the check boxe are affected too, changing their height and making them collide with vertically adjacent components.

There is a way to prevent this to happen ?

Tharon

  • Jr. Member
  • **
  • Posts: 61
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #1 on: September 22, 2021, 06:50:42 pm »
This is an example, from a tool i made some time ago.

In the left is when the tool is launched with the standard menu font size (9) and on the right is when the tool is launcher with the menu font size incresed (12).

Higher font size make the checkboxes go even lower, even making them disappear from the form.
« Last Edit: September 22, 2021, 06:53:43 pm by Tharon »

dseligo

  • Hero Member
  • *****
  • Posts: 1195
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #2 on: September 23, 2021, 07:55:11 am »
In Project options check if you selected 'Use LCL scaling (High-DPI)' and 'DPI awareness' on.

Tharon

  • Jr. Member
  • **
  • Posts: 61
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #3 on: September 23, 2021, 10:47:56 am »
Both are off.

Anyway isn't related to DPI, the DPI of my sistem is set a 100%.

Tharon

  • Jr. Member
  • **
  • Posts: 61
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #4 on: September 24, 2021, 08:51:48 pm »
After some test it seems the height of the Tcheckbox is fixed and depends on the system theme. Apparently can't be changed in Lazarus, both in design or runtime.

Don't know if this is a bug or it's caused by Windows.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #5 on: September 24, 2021, 10:15:57 pm »
I don't understand these screenshots. You say the left one is with font size 9, and the right one is with font size 12. But the texts in both images have the same size. Please post unmanipulated screenshots.

Do you work with auto-sizing and anchors? You must if you change fonts. What looks correct with one font will be awfully off with another font otherwise.

It seems to me that the radiogroup is not auto-sized. Usually AutoFill=true and AutoSize=true are the correct settings for a radiogroup.

Tharon

  • Jr. Member
  • **
  • Posts: 61
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #6 on: September 24, 2021, 11:36:32 pm »
The screenshots are not manipulated, i've only put them one near each other.

The font size i was refering isn't the one of the text, but the size of the "menu" font in windows.

As i've said in my first post, i've changed the menu font size from the Windows theme settings to have more readable menu text in Windows. After doing this the check boxes of all my lazarus programs changed size too, even at design time, even already compiled one.

No DPI have been changed in my system, and i'm not changing font in the software.
The setting i'm talking about is the one in the screenshot.

The two screenshot shows the same program (not two different version, it's the same executable) running with the two windows menu settings.

The issue isn't the radiogroup not autosized... the individuals checkboxes height of the checkboxed changed accordly to the Windows menu text size. It happens on every checkbox, not only the ones inside a radiogroup.
« Last Edit: September 24, 2021, 11:40:41 pm by Tharon »

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #7 on: September 24, 2021, 11:39:47 pm »
OK, I understand now. Which Windows version is this? I've not seen a possibility to change the menu font for a long time (or it's buried deeply in Windows 10).

Does the RadioGroup have AutoFill=true and AutoSize=true?

Tharon

  • Jr. Member
  • **
  • Posts: 61
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #8 on: September 24, 2021, 11:53:18 pm »
Windows 7, but happen in Windows 10 too if the system font is enlarged in the "ease of access" settings.

Tharon

  • Jr. Member
  • **
  • Posts: 61
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #9 on: September 25, 2021, 12:12:10 am »
Here. This is Lazarus with the program launched first with the default Windows menu text size, and then with increased Windows menu text size. I didn't change anything, only launched lazarus and loaded the project file.

The size of the checkbox height automatically changed from 19 to 25 and can't be manually resized. This happen on the compiled executable too. It doesn't matter if i compiled it when the height is 19, if i change the Windows menu text size the checkbox height changes too.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #10 on: September 25, 2021, 12:43:54 am »
The height of the checkbox is not the problem when you make sure that the position of the items in the groupbox adjusts automatically when the font size changes.

In the attached demo I am using a Groupbox and placed some checkboxes into it. The checkboxes were not positioned with the mouse but by means of the ChildSizing property of the Groupbox - look at the settings in the Object Inspector. This way the checkboxes change their position with font size. The Groupbox itself has its AutoSize property set to true and thus can adjust its size to changes in text length and item count.

Another way to achieve this is by using the AnchorEditor.

I copied the same groupbox twice and changed the font size from 0 (default), to 12 and 16. Since the layout is auto-adjusting there is no overlap.

PS.
I also tried a TCheckGroup which uses ChildSizing internally as well. But this does not work very well - TCheckgroup is quite buggy...

Tharon

  • Jr. Member
  • **
  • Posts: 61
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #11 on: September 25, 2021, 02:04:45 am »
This is the look of your example if i set the windows menu text size at 24.
I didn't changed the font size with lazarus, i've only compiled it and then changed the windows theme settings.

The height of each Checkbox grow and go outside the form.
« Last Edit: September 25, 2021, 02:17:11 am by Tharon »

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #12 on: September 25, 2021, 10:00:55 am »
I did not want to confuse you with the AnchorEditor and thus did not auto-size the form.

You must set the form's AutoSize to true. In order to avoid all controls jumping to the upper-left corner you must anchor them so that they cannot be moved with the mouse any more:
* Open the Anchor Editor.
* Select the left groupbox. Anchor its left side to the left side of the form, and its top side to the top side of the form. Adjust the distance to the form by specifying appropriate BorderSpacing values.
* Select the center groupbox. Anchor its left side to the right side of the left groupbox, anchor its top side to the top of the form.
* Select the right groupbox. Anchor its left side to the right side of the center groupbox, anchor its top side to the top of the form.
* Set the form's AutoSize to true.
* You wont see a difference, but at runtime the size of the form is adjusted such that it always encloses the three groupboxes.

I am attaching the project in this state, as well as two screenshots taken with "Ease-of-access" setting to 100% and 225%, respectively.

In case that all this is not working for you: what is your Lazarus/FPC version? What are the DPI-settings on your two systems?

Tharon

  • Jr. Member
  • **
  • Posts: 61
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #13 on: September 25, 2021, 10:14:29 am »
In your second screenshot the checkbox height changed. This is exactly what i want to avoid.
Checkboxes should not change at all if the ease of access is modified, or the component is not reliable.

The program UI should remain the same on every system, regardless of the Windows settings.
Is not a matter of keep the boxes inside the form or the radiogroup, but keep them in their exact place.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Strange behaviour of TCheckBox and Windows Menu settings
« Reply #14 on: September 25, 2021, 10:25:08 am »
happen in Windows 10 too if the system font is enlarged in the "ease of access" settings.

Be careful with this method of improving legibility of your applications. It is a system-wide settings and most programs cannot handle this correctly, not even the Windows explorer - see screenshot taken from the Explorer at 255% setting.

It is better to change the dpi of the monitor. In older Windows, the correspondig settings were named "normal fonts", "large fonts" or similar, in Win 10 it is on the "Display" page, "Change the size of apps and text" (or similar, translated from German). It is a system-wide setting, too, but handled by many programs correctly. Lazarus takes care of it by means of LCLScaling (which - as you wrote - is turned off in your application. Why? No good idea...).

 

TinyPortal © 2005-2018