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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
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

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How to make a TStaticText control appear on top of the form?

Free Pascal - Lazarus mailing list
On Wed, 03 Feb 2021 14:36:38 +0100, Bo Berglund via lazarus
<[hidden email]> 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.


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How to make a TStaticText control appear on top of the form?

Free Pascal - Lazarus mailing list
On Thu, 04 Feb 2021 18:43:55 +0100, Bo Berglund via lazarus
<[hidden email]> wrote:

>On Wed, 03 Feb 2021 14:36:38 +0100, Bo Berglund via lazarus
><[hidden email]> 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

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus