I need to create FMX form dynamically with a fixed width and height, but I get bigger size when removing borders or setting to BorderStyle=Single.
When setting BorderStyle to None or Single, even setting a fixed ClientWidth and ClientHeight, the size of the form keeps the original Windows border, so If I create a Sizeable (Default) Form, both of forms remains with the same size, incorrectly.
Please see the image to better understand:
Using Delphi 10.4 and Windows 11, but I have tested in others environments and it has the same problem.
var
Form: TForm;
Shape: TRectangle;
begin
//Form with Border Sizeable
Form := TForm.CreateNew(Application);
Form.BorderStyle := TFmxFormBorderStyle.Sizeable;
Form.Fill.Color := TAlphaColors.Yellow;
Form.Fill.Kind := TBrushKind.Solid;
Form.ClientWidth := 300;
Form.ClientHeight := 300;
Shape := TRectangle.Create(Form);
Shape.Parent := Form;
Shape.SetBounds(0, 0, 300, 300);
Form.Show;
//Form with Border Single
Form := TForm.CreateNew(Application);
Form.BorderStyle := TFmxFormBorderStyle.Single;
Form.Fill.Color := TAlphaColors.Yellow;
Form.Fill.Kind := TBrushKind.Solid;
Form.ClientWidth := 300;
Form.ClientHeight := 300;
Shape := TRectangle.Create(Form);
Shape.Parent := Form;
Shape.SetBounds(0, 0, 300, 300);
Form.Show;
//Form with Border None
Form := TForm.CreateNew(Application);
Form.BorderStyle := TFmxFormBorderStyle.None;
Form.Fill.Color := TAlphaColors.Yellow;
Form.Fill.Kind := TBrushKind.Solid;
Form.ClientWidth := 300;
Form.ClientHeight := 300;
Shape := TRectangle.Create(Form);
Shape.Parent := Form;
Shape.SetBounds(0, 0, 300, 300);
Form.Show;
end;
Doing the same thing in form designer, the problems does not occurs.
If I set Width and Height instead of ClientWidth and ClientHeight when BorderStyle = None, it works, but when I'm setting BorderStyle = Single, the problem occurs, and in this case I can't set Width and Height because I still have form border.
In VCL environment, this works exactly as expected, where the real window size (considering borders) are different by changing border, keeping always ClientRect (ClientWidth and ClientHeight) the same.
Expected (running in VCL with same sizes): All forms have same ClientRect, no matter the border changes.

