I have a form in my application which is triggered with ShowModal. I have set the BorderStyle to ToolWindow because I don't want it to be resizable. However, I discovered that it can still be maximised by double clicking the title bar. I don't want that. To prevent this I tried setting biMaximize to False in BorderIcons. This seems to work when I run the application from the IDE - it can no longer be maximised by double clicking the title bar. However, when I run the application directly from the compiled executable, that form always appears the wrong size (much too high)! WindowState is set to wsNormal. My application is built for Windows and I'm running on Windows 10.
How can I create a form that cannot be resized and why is it behaving differently when run outside the IDE?
Edit: I've discovered that this is related to the Windows display settings with multiple monitors. My screen scale is set to 125% on one monitor and 100% on the other. If I set both to 100% then the form appears the right size. If I turn off one monitor then it also appears correctly. My main question is, how can I prevent a double click of the title bar maximising the form without setting biMaximize to false?
See the following example. To reproduce the error you will need two monitors. Set one to 100% scale and the other to 125% in Display Settings. Then build the app for Windows and run the exe from outside the IDE. Click the button to show the second form and it appears much too large. I'd appreciate if anyone could confirm that they get the error and also if it still occurs in the latest version of 10.4. If so then I will report it.
Project:
program Project1;
uses
System.StartUpCopy,
FMX.Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
Main Form and Unit:
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 480
ClientWidth = 640
Position = ScreenCenter
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
DesignerMasterStyle = 0
object Button1: TButton
Position.X = 256.000000000000000000
Position.Y = 168.000000000000000000
Size.Width = 137.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
Text = 'Show ToolWindow'
OnClick = Button1Click
end
end
.
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls, Unit2;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.ShowModal;
end;
end.
Second Form and Unit:
object Form2: TForm2
Left = 0
Top = 0
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = ToolWindow
Caption = 'Form2'
ClientHeight = 237
ClientWidth = 344
Position = ScreenCenter
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
DesignerMasterStyle = 0
object Button1: TButton
ModalResult = 8
Position.X = 136.000000000000000000
Position.Y = 208.000000000000000000
Text = 'Close'
end
end
.
unit Unit2;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.fmx}
end.