When maximizing a plain TForm via Form.WindowState := wsMaximized;
on the main screen, the property Left is -8 and Width is e.g. Screen.Monitors[0].BoundsRect.Width+8
.
When i want to set the Forms absolute position via 'Form.Top, .Left, .Width, .Height' to the active Monitors WorkingArea, there is always a gap due to the missing 8 pixels.
Where is the additional offset of 8 in each direction coming from and why is it necessary?
My test form (with a button to toggle some positioning states)
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
FState: Integer;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
LBRect,
LWRect,
LFCRect,
LFBRect: TRect;
begin
LBRect := Screen.Monitors[0].BoundsRect;
LWRect := Screen.Monitors[0].WorkareaRect;
LFCRect := Self.ClientRect;
LFBRect := Self.BoundsRect;
case FState of
0:
begin
Top := 100;
Left := 100;
Width := 800;
Height := 600;
end;
1:
begin
WindowState := wsMaximized;
end;
2:
begin
WindowState := wsNormal;
end;
3:
begin
Self.Top := LBRect.Top;
Self.Left := LBRect.Left;
Self.Width := LBRect.Width;
Self.Height := LBRect.Height;
end;
4:
begin
Self.Top := LWRect.Top;
Self.Left := LWRect.Left;
Self.Width := LWRect.Width;
Self.Height := LWRect.Height;
end;
end;
Inc(FState);
FState := FState mod 5;
end;
end.
When setting the state to 3 or 4, there will be a gap. Why?