BorderStyle = bsNone + WindowState = wsMaximized, doesn't work
Original Reporter info from Mantis: VirtUX
-
Reporter name: Vitaly Yakunin
Original Reporter info from Mantis: VirtUX
- Reporter name: Vitaly Yakunin
Description:
If TForm is set to BorderStyle: = bsNone, then an attempt to make WindowState: = wsMaximized will be ignored by the class.
If this is a bug, is there an alternative solution to the problem? For example, it could be like this:
Form.BoundsRect: = Form.Monitor.WorkareaRect;
But!
If the desktop panel is on the left / top and more than one monitor is connected, then Form.Monitor.WorkareaRect.Left and Form.Monitor.WorkareaRect.Top are always zero.
If you do this on the main monitor, then the window is displaced by the width of the panel beyond the border of the monitor. If you do this on an additional monitor, the window will be hidden under the panel itself (if desktop panel available on this monitor).
That is, it turns out that I need to calculate the width and position of the desktop panel, and then Ican expand the window as needed by subtracting that desktop panel from the WorkareaRect.
Question: How to calculate the width and position of the desktop panel on the desktop?
It should also be borne in mind that there may be several panels. And still wondering how it will be on macOS, Windows and Linux?
If the monitor is the only one, then Form.Monitor.WorkareaRect.Left and Form.Monitor.WorkareaRect.Top wondering the desktop panel and the readings are correct.
Steps to reproduce:
To reproduce the bug "wsMaximized":
- In the designer, we set property FormAny.BorderStyle = bsNone.
- In runtime, we set property FormAny.WindowState = wsMaximized.
- FormAny remains unchanged.
To reproduce the bug "WorkareaRect":
1. Connect more than one monitor.
2. Set desktop bar to the left or top.
2. Execute code :
procedure TForm1.Button1Click(Sender: TObject);
var
_r: TRect;
begin
_r:= Monitor.WorkareaRect;
form1.BoundsRect:= _r;
ShowMessage(
'Left: '+_r.Left.ToString+
' Top: '+_r.Top.ToString
);
end;
Mantis conversion info:
- Mantis ID: 39158
- OS: KDE Neon
- OS Build: 5.22
- Monitored by: » VirtUX (Vitaly Yakunin)