0

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.
XylemFlow
  • 963
  • 5
  • 12
  • I can not test in any newer than Delphi 10.1. In my test I can not reproduce the problem. Are you sure you tested outside the IDE with your latest version of the form? If you are, then please provide a [mre] – Tom Brunberg Jul 13 '21 at 14:00
  • Yes, I'm sure. I see in the bug list for 10.4 there's a mention of hints not working when biMaximise is disabled. Perhaps this is related. I could create an example, but I think I've included everything in my description. Everything about the form is default apart from those things I mention. – XylemFlow Jul 13 '21 at 14:04
  • I've discovered that this is related to Scale in the windows display settings. Can you try again with 125% scale? – XylemFlow Jul 13 '21 at 14:30
  • I tried with 125%. Nothing unexpected, the secondary window is not maximized by a double click of the title bar. – Tom Brunberg Jul 13 '21 at 14:38
  • OK, then it must be because I have 2 screens with different Scales. If I turn off the screen with scale of 100% and keep the screen with 125% then I don't have a problem either. I've noticed other issues related to multiple monitors with different scales. I still need to find an alternative solution incase someone else is using multiple monitors in this way. – XylemFlow Jul 13 '21 at 14:42
  • I see you have edited: in last sentence *...how can I prevent a double click of the title bar maximising the form without setting biMaximize to false?* Originally you said that you have set `biMaximise` false. Why can you not set it false? – Tom Brunberg Jul 13 '21 at 14:49
  • It's when I set biMaximise to false that I get the wrong size form issue (with multiple monitors set to different scales). – XylemFlow Jul 13 '21 at 14:53
  • To prevent double-click (on title bar) from maximizing you must set `biMaximize=False`. If you set it `True` then the normal behaviour is to maximize / restore on title bar double-click, (or clicking on the maximize / restore button which is hidden due to the `BorderStyle=ToolWindow` setting). In all my previous testing I had `biMaximize=False`. – Tom Brunberg Jul 13 '21 at 15:20
  • OK, then I will have to permit users to maximise the form (biMaximise=True) for now to avoid the wrong size window issue. It's a big issue because the window ends up larger than the screen which makes it difficult to close. Are you able to test with multiple monitors to reproduce the issue? – XylemFlow Jul 13 '21 at 15:26
  • No, I can not test with multiple monitors. – Tom Brunberg Jul 13 '21 at 15:38

0 Answers0