Recent

Author Topic: Left value of the maximized form  (Read 709 times)

krzynio

  • Jr. Member
  • **
  • Posts: 99
    • Krzynio's home page
Left value of the maximized form
« on: November 21, 2023, 01:13:09 pm »
Hi. Why Left parameter of maximized form is not zero but -8? Border size is zero.
Tested on Windows 11 with Lazarus 2.2.6
« Last Edit: November 21, 2023, 01:50:33 pm by krzynio »
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

Handoko

  • Hero Member
  • *****
  • Posts: 5101
  • My goal: build my own game engine using Lazarus
Re: Left value of the maximized form
« Reply #1 on: November 21, 2023, 01:54:08 pm »
Can you provide a demo?

I tested it on my Lazarus 2.2.6 Ubuntu Mate 23.10, it showed zero, this is my code:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   i: Integer;
  4. begin
  5.   WindowState := wsMaximized;
  6.   for i := 1 to 100 do
  7.     Application.ProcessMessages;
  8.   Caption := Left.ToString;
  9. end;

The for-loop is used for making some delays so the Left property can have correct value.

krzynio

  • Jr. Member
  • **
  • Posts: 99
    • Krzynio's home page
Re: Left value of the maximized form
« Reply #2 on: November 21, 2023, 02:15:41 pm »
Thank you for your interest. Could you try this please?
1. start a new project
2. put a button on from and write a procedure onbuttonclick: showmessage(IntToStr(Form1.Left))
3. Run the program and click the button. The Left should have a positive value, i.e. 861
4. Maximize the form and press the button again. Now Left is -8 ??? what I do not understand.

I have to add that I work on virtual machine. Maybe this helps.
« Last Edit: November 21, 2023, 02:18:01 pm by krzynio »
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

Handoko

  • Hero Member
  • *****
  • Posts: 5101
  • My goal: build my own game engine using Lazarus
Re: Left value of the maximized form
« Reply #3 on: November 21, 2023, 02:42:48 pm »
I could be wrong. But I believe Windows consider the form style border as part of the form position. For example you can see the thick border of the form that run on WinXP from the screenshot below, it gave me -4 px when maximized. I opened and zoomed it using GIMP, and I could clearly see the thickness of the border is 4px.

krzynio

  • Jr. Member
  • **
  • Posts: 99
    • Krzynio's home page
Re: Left value of the maximized form
« Reply #4 on: November 21, 2023, 06:17:49 pm »
I think the same, probably in Windows 11 the frame is invisible but still exists.
It looks strange but there is some logic in this.
When window is maximized the frame is outside of the desktop and you cannot catch it for windows resizing.
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9663
  • Debugger - SynEdit - and more
    • wiki
Re: Left value of the maximized form
« Reply #5 on: November 21, 2023, 09:10:07 pm »
I am on Windows 10

Maximizing the form, and left = -1448 => But then that is on a monitor that starts at -1440

On a normal monitor, I get -8 too

That seems to go back for some time => Lazarus 1.8 has that too.

ASerge

  • Hero Member
  • *****
  • Posts: 2194
Re: Left value of the maximized form
« Reply #6 on: November 21, 2023, 09:34:41 pm »
Hi. Why Left parameter of maximized form is not zero but -8? Border size is zero.
Starting with Windows 8, Microsoft has added transparent shadows to the window for beauty. Unfortunately, the company did not make the appropriate changes to the Windows API, as a result, many applications had to be changed to take into account these additional boundaries.

 

TinyPortal © 2005-2018