Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2021-02

How to make a TStaticText control appear on top of the form?

3 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I have a very special transparent form where there is a small opaque area in one corner.
Here I have two TStaticText controls which are showing the size of the form and displays an X respectively. These are updated during resizing so the form state is visible. This works fine on my Win10 computer but when I copy the application to my wife's laptop they are hidden apparently below the main form when I start the app...

Very strange, the same binary behaves differently on two HP laptops both running Windows 10 and both a little more than one year old.

How can I force these controls on top of the form so they are always visible?

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 5 lines
Very strange, the same binary behaves differently on two HP laptops both running Windows 10 and both a little more than one year old. How can I force these controls on top of the form so they are always visible?

So I found out what causes this to happen:

On my laptop the screen setting is 100%, whereas on the other laptop it is at 125%.
Changing that laptop back to 100% makes the missing controls appear on this laptop too.

Question:
---------
How come some Lazarus controls cannot display on Windows 10 if the screen is set to 125% sizing? Is this by design or is it just overlooked?

The monitor is 1920x1080.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 23 lines
On Wed, 03 Feb 2021 14:36:38 +0100, Bo Berglund via lazarus wrote: >Very strange, the same binary behaves differently on two HP laptops both running >Windows 10 and both a little more than one year old. > >How can I force these controls on top of the form so they are always visible? > So I found out what causes this to happen: On my laptop the screen setting is 100%, whereas on the other laptop it is at 125%. Changing that laptop back to 100% makes the missing controls appear on this laptop too. Question: --------- How come some Lazarus controls cannot display on Windows 10 if the screen is set to 125% sizing? Is this by design or is it just overlooked? The monitor is 1920x1080.

While hunting this problem I discovered that the TStaticText controls set to anchor right and top actually were placed erroneously on the form if the program is executed on a Win10 PC with the display set at 125% when the applicaton was created on a PC with display at 100%.

So the two controls should be placed on top and right on the main form and this is where they are displayed on a PC with display set to 100%. But when I set the display to 125% they move left a distance that makes them invisible!!!
By adding this code to the function that creates the form transparency shape I get the controls to display correctly in both 125% and 100% modes.

    stxClose.Left := Self.Width - stxClose.Width;
    stxSize.Left := stxClose.Left - stxSize.Width;

To me it looks like this is a bug in Lazarus (or Fpc).

It seems like when the form is created in Lazarus and alignment is set to [akTop,akRight] the location of the controls is somehow stored in the executable as pixels.
Then when the application starts on a PC with 125% Lazarus/Fpc adjusts the form size and thus also the positions and sizes of all components on the form accordingly.
But the left property of TStaticText is apparently not adjusted so it uses the smaller value from the 100% development PC rather than the bigger value on the 125% PC.

The result of this is that the components start out at a location well to the left of the intended position. And in my case they move into the invisible transparent part of the form...

Lazarus 2.0.10, Fpc 3.2.0 on Windows 10 x64

Bo Berglund Developer in Sweden

Reply by email