Recent

Author Topic: wsMaximised and Constraints  (Read 568 times)

petevick

  • Sr. Member
  • ****
  • Posts: 419
wsMaximised and Constraints
« on: July 15, 2024, 12:59:52 pm »
Could someone explain to me why, when you set the Forms WindowState to wsMaximised in code, at run time any constraints that have been set for the form are ignored, and the form fills the screen, but if use the system min/max icons at run time the constraints are obeyed.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

tetrastes

  • Hero Member
  • *****
  • Posts: 590
Re: wsMaximised and Constraints
« Reply #1 on: July 15, 2024, 04:43:01 pm »
Could someone explain to me why, when you set the Forms WindowState to wsMaximised in code, at run time any constraints that have been set for the form are ignored, and the form fills the screen

Cannot confirm at Win10 Laz3.2 fpc 3.2.2. This works as expected:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.     Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.     { TForm1 }
  13.  
  14.     TForm1 = class(TForm)
  15.         Button1: TButton;
  16.         procedure Button1Click(Sender: TObject);
  17.     private
  18.  
  19.     public
  20.  
  21.     end;
  22.  
  23. var
  24.     Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.Button1Click(Sender: TObject);
  33. begin
  34.     WindowState := wsMaximized;
  35. end;
  36.  
  37. end.
  38.  

You have to show your code.

petevick

  • Sr. Member
  • ****
  • Posts: 419
Re: wsMaximised and Constraints
« Reply #2 on: July 15, 2024, 05:14:33 pm »

Cannot confirm at Win10 Laz3.2 fpc 3.2.2. This works as expected:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}Thanks for the reply tetrastes.
  4.  
  5. interface
  6.  
  7. uses
  8.     Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.     { TForm1 }
  13.  
  14.     TForm1 = class(TForm)
  15.         Button1: TButton;
  16.         procedure Button1Click(Sender: TObject);
  17.     private
  18.  
  19.     public
  20.  
  21.     end;
  22.  
  23. var
  24.     Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.Button1Click(Sender: TObject);
  33. begin
  34.     WindowState := wsMaximized;
  35. end;
  36.  
  37. end.
  38.  

You have to show your code.
Sorry, I should have stated that the issue is in Linux, but I've just tried in Win10 and although any Constraint settings are observed the taskbar is not taken into consideration, so the bottom of the maximised form is hidden behind the taskbar as there is no constraint on the height.

As for code, exactly as you have, WindowState := wsMaximized;.

So to sum up, in Linux WindowState := wsMaximized ignores any constraint settings. In Windows WindowState := wsMaximized observes constraints but ignores the taskbar height. I've doubled checked these results with your code and get the same.
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

tetrastes

  • Hero Member
  • *****
  • Posts: 590
Re: wsMaximised and Constraints
« Reply #3 on: July 15, 2024, 05:37:29 pm »
Sorry, I should have stated that the issue is in Linux, but I've just tried in Win10 and although any Constraint settings are observed the taskbar is not taken into consideration, so the bottom of the maximised form is hidden behind the taskbar as there is no constraint on the height.

On the contrary, this is due to the constraints, if you set MaxHeight greater than Screen Height - Taskbar Height. And if you set MaxHeight greater than Screen Height, the bottom of form will be invisible at all.
« Last Edit: July 15, 2024, 05:39:58 pm by tetrastes »

 

TinyPortal © 2005-2018