属性“ofOverwritePrompt”当在Delphi 10.1 Berlin中使用VCL样式时,TSaveDialog不起作用 [英] Property "ofOverwritePrompt" for TSaveDialog does not work when VCL Styles are used in Delphi 10.1 Berlin

查看:721
本文介绍了属性“ofOverwritePrompt”当在Delphi 10.1 Berlin中使用VCL样式时,TSaveDialog不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 创建新的VCL Forms应用程序

  2. 在主窗体上添加一个Tbutton和一个TSaveDialog


  3. 在SaveDialog1的属性中将ofOverwritePrompt设置为True


  4. 使用:

      procedure TForm1.Button1Click(Sender:TObject); 
    begin
    SaveDialog1.Execute();
    结束


  5. 运行应用程序。按按钮执行保存对话框。尝试保存到已经存在的文件。
    如果要替换文件,将显示一个消息框。按取消。到目前为止都很好。关闭应用程序。


  6. 转到项目/选项/应用程序/外观,然后选择自定义样式(例如Amakrits)。将Amakrits设置为默认样式。


  7. 按照上述#5运行应用程序。只会显示一小段消息框。您必须按Enter才能继续。

(使用TFileSaveDialog会产生相同的结果)



如果我使用Delphi XE8编译并运行应用程序,那么保存对话框窗口似乎使用默认的窗口样式,即使选择了其他样式也是如此。



编辑:
我有Windows 10 pro。源代码编译为win32与Delphi 10.1柏林。
替换消息框部分隐藏。只显示一个小的左上角部分,见图。





这里是使用XE8 win32编译的:





Ps。我使用默认的100%比例因子。



使用win64(Delphi 10.1 Berlin)编译似乎很好:





所以,编译到win32对我来说不行,但是64位会。任何线索?



编辑:使用GetSaveFileName(OFN)尝试也不适用于我在win32(win 64可以):



解决方案

你可以避免这个问题使用


  1. Create a new VCL Forms application
  2. On the main form add a Tbutton and a TSaveDialog

  3. Set "ofOverwritePrompt" to True in properties for the SaveDialog1

  4. Use:

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      SaveDialog1.Execute();
    end;
    

  5. Run the app. Press the button to execute the save dialog. Try to save to a file that already exists. A message box appears if you want to replace the file. Press cancel. All fine so far. Close the app.

  6. Go to Project/Options/Application/Appearance and select a Custom style (e.g. Amakrits). Set Amakrits as the default style.

  7. Run the app as in #5 above. Only a small bit of the message box will be shown. You will have to press Enter to be able to continue.

(Using a TFileSaveDialog will give the same result)

If I compile and run the app using Delphi XE8 it will be ok since the save dialog window seems to use the default windows style even if another style is chosen.

Edit: I have Windows 10 pro. Source compiled as win32 with Delphi 10.1 Berlin. The replace message box is partly hidden. Only a small top left part is shown, see figure.

And here it is compiled with XE8 win32:

Ps. I am using the default 100% scale factor.

Compiling with win64 (Delphi 10.1 Berlin) seems to be ok:

So, compiling to win32 does not work for me, but 64-bit will. Any clues?

Edit: Trying with "GetSaveFileName(OFN)" will also not work for me in win32 (win 64 is ok):

解决方案

You can avoid this issue using the dialog styling code of the VCL Styles Utils project.

Just Add these units to your project.

uses
  Vcl.Styles.Utils.Menus, //Popup and Shell Menus (class #32768)
  Vcl.Styles.Utils.Forms, //dialogs box (class #32770)
  Vcl.Styles.Utils.StdCtrls, //buttons, static, and so on
  Vcl.Styles.Utils.ComCtrls, //SysTreeView32, SysListView32
  Vcl.Styles.Utils.ScreenTips, //tooltips_class32 class
  Vcl.Styles.Utils.SysControls,
  Vcl.Styles.Utils.SysStyleHook;

{$R *.dfm}

procedure TForm26.Button1Click(Sender: TObject);
begin
  UseLatestCommonDialogs := false;
  SaveDialog1.Execute();
end;

这篇关于属性“ofOverwritePrompt”当在Delphi 10.1 Berlin中使用VCL样式时,TSaveDialog不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆