Recent

Author Topic: Maximizing form - problem  (Read 2432 times)

J-23

  • Full Member
  • ***
  • Posts: 108
Maximizing form - problem
« on: December 07, 2019, 05:18:43 pm »
Hi,
I have form:
Code: Pascal  [Select][+][-]
  1. object Form1: TForm1
  2.   Left = 383
  3.   Height = 240
  4.   Top = 250
  5.   Width = 320
  6.   BorderIcons = [biSystemMenu]
  7.   Caption = 'Form1'
  8.   ClientHeight = 240
  9.   ClientWidth = 320
  10.   WindowState = wsMaximized
  11.   object StatusBar1: TStatusBar
  12.     Left = 0
  13.     Height = 20
  14.     Top = 220
  15.     Width = 320
  16.     Panels = <>
  17.   end
  18. end                    
  19.  
The form at the start is maximized and only has a close button and StatusBar

However, the form is maximized in a bad way. StatusBar cannot be seen. I suspect that this is an error that is described in the commentary in the procedure:
Code: Pascal  [Select][+][-]
  1. class procedure TWin32WSCustomForm.ShowHide(const AWinControl: TWinControl);
  2. const
  3.   WindowStateToFlags: array[TWindowState] of DWord = (
  4.  { wsNormal     } SW_SHOWNORMAL, // to restore from minimzed/maximized we need to use SW_SHOWNORMAL instead of SW_SHOW
  5.  { wsMinimized  } SW_SHOWMINIMIZED,
  6.  { wsMaximized  } SW_SHOWMAXIMIZED,
  7.  { wsFullScreen } SW_SHOWNORMAL  // win32 has no fullscreen window state
  8.   );
  9. var
  10.   Flags: DWord;
  11. begin
  12.   if AWinControl.HandleObjectShouldBeVisible then
  13.   begin
  14.     Flags := WindowStateToFlags[TCustomForm(AWinControl).WindowState];
  15.     Windows.ShowWindow(AWinControl.Handle, Flags);
  16.     { ShowWindow does not send WM_SHOWWINDOW when creating overlapped maximized window }
  17.     { TODO: multiple WM_SHOWWINDOW when maximizing after initial show? }
  18.     if Flags = SW_SHOWMAXIMIZED then
  19.       Windows.SendMessage(AWinControl.Handle, WM_SHOWWINDOW, 1, 0);
  20.   end
  21.   else
  22.   if fsModal in TCustomForm(AWinControl).FormState then
  23.     Windows.SetWindowPos(AWinControl.Handle, 0, 0, 0, 0, 0,
  24.       SWP_NOSIZE or SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or SWP_HIDEWINDOW)
  25.   else
  26.     Windows.ShowWindow(AWinControl.Handle, SW_HIDE);
  27. end;
  28.  

I will gladly correct this error and publish a solution for the Lazarus community just wondering if there is LCL documentation for programmers or if I only have to analyze the code.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Maximizing form - problem
« Reply #1 on: December 07, 2019, 05:41:05 pm »
Hi!

What do you mean - "Cannot be seen"?

Is it hidden by the taskbar? Is it out of screen? Is it not visible anymore?

Please describe the problem exact.

Winni

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Maximizing form - problem
« Reply #2 on: December 07, 2019, 06:48:55 pm »
I can reproduce the issue (Win 10, Laz trunk, fpc 3.0.4) for a form with initial WindowState = wsMaximized, but only when the bsMaximize style is removed from the BorderIcons: the statusbar is covered by the TaskBar of the desktop. However, Delphi has the same behavior, therefore I think the issue has its origin in Windows.

You can prevent the statusbar of the maximized form being covered by the TaskBar when you switch the FormStyle to fsStayOnTop.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Maximizing form - problem
« Reply #3 on: December 07, 2019, 06:54:34 pm »
Hi!

If it is the problem descibed by @wp then I recommend the tasbar settings of window:

automatic hide taskbar.


That solves all these problems.

Winni
« Last Edit: December 07, 2019, 07:01:29 pm by winni »

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Maximizing form - problem
« Reply #4 on: December 07, 2019, 07:57:24 pm »
Hi!

What do you mean - "Cannot be seen"?

Is it hidden by the taskbar? Is it out of screen? Is it not visible anymore?

Please describe the problem exact.

Winni
hi,
The point is in the first screenshot you have the window displayed correctly, but with the maximize and minimize button. After disabling these two buttons. (BorderIcons = [biSystemMenu]) we have an image that looks like the second screenshot. Which seems to be invalid.

Post WP describes that similar operation is in Delphi so it may actually be a problem on the Win32 side.

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: Maximizing form - problem
« Reply #5 on: December 07, 2019, 08:05:30 pm »
Use default BorderIcons and add code:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormActivate(Sender: TObject);
  2. begin
  3.   BorderIcons := [biSystemMenu];
  4. end;

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: Maximizing form - problem
« Reply #6 on: December 07, 2019, 10:44:41 pm »
if you do this it may cause issues because there are apps that take the whole screen and then have the task bar drop down so the app becomes the whole screen.

  I also remember a windows state that is in the TCustomForm but not supported natively in windows. Maybe the two of them are getting mixed up?
The only true wisdom is knowing you know nothing

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Maximizing form - problem
« Reply #7 on: December 08, 2019, 12:04:34 am »
Use default BorderIcons and add code:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormActivate(Sender: TObject);
  2. begin
  3.   BorderIcons := [biSystemMenu];
  4. end;

This solution seems sufficient. Thank you

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Maximizing form - problem
« Reply #8 on: December 08, 2019, 12:09:47 am »
if you do this it may cause issues because there are apps that take the whole screen and then have the task bar drop down so the app becomes the whole screen.

  I also remember a windows state that is in the TCustomForm but not supported natively in windows. Maybe the two of them are getting mixed up?

The case you describe should be solved by the option (WindowState = wsFullScreen)

 

TinyPortal © 2005-2018