Recent

Author Topic: DPI scaling breaks anchoring in a TNotebook  (Read 351 times)

kupferstecher

  • Hero Member
  • *****
  • Posts: 603
DPI scaling breaks anchoring in a TNotebook
« on: November 02, 2024, 07:45:16 pm »
Hi all,

in my application I use a TNotebook that uses the whole Form (alClient). The pages have controls that are anchored to all sides to resize them according the Forms size, also some to the right to move them. When I compile the program and run it on the same system it works alright, but if I go to an other system with another dpi scaling then the anchoring doesn't work any more and all controls are like they are anchored left/top only. If on the other hand I compile the project on that computer then everything works there, but not with the copied Binary to the first computer. I think its because of the dpi scaling, as DoAutoAdjustLayout is triggered on the other system (each), but not if the program is executed on the same PC where it was compiled.

As a workaround I tried to set the anchors on the OnShow again. But this only works for the visible page of the Notebook, the other still has some problems. Then I also tried to set the dimensions in the Forms OnResize event and therefore removed all custom anchors (i.e. set them to default left/top). Even this doesn't work properly. While the visible page while resizing is fine, the dimensions of controls in the unvisible page are incorrect after switching to this page. It gets "repaired", though when I resize the Form. Seems the internal values were ok, but not updated properly.

Attached a minimum project. Can please someone check if the issue is reproducable?

Thanks!

Lazarus 3.6 (64bit) on Win7 and Win10

TRon

  • Hero Member
  • *****
  • Posts: 3618
Re: DPI scaling breaks anchoring in a TNotebook
« Reply #1 on: November 02, 2024, 07:53:55 pm »
Is this perhaps the same behaviour as described in this thread ?
This tagline is powered by AI

wp

  • Hero Member
  • *****
  • Posts: 12456
Re: DPI scaling breaks anchoring in a TNotebook
« Reply #2 on: November 02, 2024, 08:28:46 pm »
I can confirm this with your demo, but when I rebuild the same project with a TPageControl, the issue does not occur. Seems to be something in the TNotebook...

As a workaround, you can use "full anchoring" by means of the AnchorEditor. This way your demo works as well - see attachment.

kupferstecher

  • Hero Member
  • *****
  • Posts: 603
Re: DPI scaling breaks anchoring in a TNotebook
« Reply #3 on: November 02, 2024, 09:32:06 pm »
Thanks for the example, I tested and it works here, too.

As the issue is reproducable, I filed a bug report:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41221

Thanks for the help!

 

TinyPortal © 2005-2018