【发布时间】:2022-01-07 07:03:06
【问题描述】:
在某些情况下,应该是模态的表单或对话框没有停留在顶部。我正在使用 10.4 为 Windows 构建。这是一个涉及两个表单和一个 TSaveDialog 的简单示例。
复制问题:
- 在 Windows 中运行应用程序
- 单击“显示窗口”按钮(您应该会看到 Form2)
- 单击“显示保存对话框”按钮(您应该会看到保存对话框)
- 单击不属于应用程序的另一个窗口,例如资源管理器窗口
- 单击表格 2。 Form1 现在将在前面
如果您重复此操作但首先最大化 Form1,那么用户在不从任务管理器关闭程序或使用一些专业的 windows 知识的情况下解决问题并不容易。
表格1:
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 = 264.000000000000000000
Position.Y = 168.000000000000000000
Size.Width = 97.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
Text = 'Show Window'
OnClick = Button1Click
end
end
表格2:
object Form2: TForm2
Left = 0
Top = 0
Caption = 'Form2'
ClientHeight = 333
ClientWidth = 489
Position = ScreenCenter
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
DesignerMasterStyle = 0
object Button1: TButton
Position.X = 184.000000000000000000
Position.Y = 136.000000000000000000
Size.Width = 113.000000000000000000
Size.Height = 41.000000000000000000
Size.PlatformDefault = False
Text = 'Show Save Dialog'
OnClick = Button1Click
end
object SaveDialog1: TSaveDialog
Left = 80
Top = 40
end
end
单元1:
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, Unit2,
FMX.Controls.Presentation, FMX.StdCtrls;
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.Show;
end;
end.
单元2:
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;
SaveDialog1: TSaveDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.fmx}
procedure TForm2.Button1Click(Sender: TObject);
begin
SaveDialog1.Execute;
end;
end.
我没有在 VCL 应用程序中看到这种行为(模式窗口始终位于顶部)。我还在 FMX 应用程序中看到了使用 ShowModal 显示的表单甚至使用 ShowMessage 创建的消息窗口的问题。使用 TDialogServiceSync.ShowMessage 似乎有助于防止这种情况发生,但即便如此,一些用户也会遇到同样的问题。
为什么会发生这种情况,我可以做些什么来解决它?
【问题讨论】:
标签: delphi firemonkey delphi-10.4-sydney