首页 > 解决方案 > FMX:如何创建无法最大化的 ToolWindow 表单?

问题描述

我的应用程序中有一个由 ShowModal 触发的表单。我已将 BorderStyle 设置为 ToolWindow,因为我不希望它可以调整大小。但是,我发现它仍然可以通过双击标题栏来最大化。我不想那样。为了防止这种情况,我尝试在 BorderIcons 中将 biMaximize 设置为 False。当我从 IDE 运行应用程序时,这似乎有效 - 通过双击标题栏不再可以最大化它。但是,当我直接从已编译的可执行文件运行应用程序时,该表单总是显示错误的大小(太高了)!WindowState 设置为 wsNormal。我的应用程序是为 Windows 构建的,我在 Windows 10 上运行。

如何创建一个无法调整大小的表单,为什么它在 IDE 外运行时表现不同?

编辑:我发现这与具有多个显示器的 Windows 显示设置有关。我的屏幕比例在一台显示器上设置为 125%,在另一台显示器上设置为 100%。如果我将两者都设置为 100%,那么表单会显示正确的大小。如果我关闭一台显示器,那么它也会正确显示。我的主要问题是,如何防止双击标题栏以最大化表单而不将 biMaximize 设置为 false?

请参见以下示例。要重现错误,您需要两台显示器。在显示设置中将一个设置为 100%,另一个设置为 125%。然后为 Windows 构建应用程序并从 IDE 外部运行 exe。单击按钮以显示第二个表单,它看起来太大了。如果有人能确认他们收到了错误,并且如果它仍然出现在最新版本的 10.4 中,我将不胜感激。如果是这样,那么我会报告它。

项目:

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.

主要形式及单位:

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.

第二种形式和单位:

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.

标签: delphifiremonkeydelphi-10.4-sydney

解决方案


推荐阅读