简体   繁体   English

我可以在Delphi中更改TSavetextfiledialog的保存按钮上的标题吗?

[英]Can I change the caption on the save button of a TSavetextfiledialog in Delphi?

I have a TSavetextfiledialog where the user selects a filename for saving, but the save doesn't happen immediately. 我有一个TSavetextfiledialog,用户选择一个文件名进行保存,但保存不会立即发生。 Therefore I would like the save button to display "select" rather than "save". 因此我希望保存按钮显示“选择”而不是“保存”。 Can the caption of the button be changed? 可以更改按钮的标题吗?

在此输入图像描述

Since this is an old style common file open dialog, you can use CDM_SETCONTROLTEXT message on the item having IDOK identifier for the parent of the VCL's dialog handle. 由于这是旧式公共文件打开对话框,因此可以对具有IDOK标识符的项目使用CDM_SETCONTROLTEXT消息,该标识符用于VCL对话框句柄的父级。 For IDs of other items, see documentation on Explorer-Style Control Identifiers . 有关其他项的ID,请参阅Explorer样式控件标识符的文档。 Here is calling it in the OnShow event handler: 这是在OnShow事件处理程序中调用它:

uses
  commdlg;

procedure TForm2.SaveTextFileDialog1Show(Sender: TObject);
begin
  SendMessage(GetParent(SaveTextFileDialog1.Handle),
      CDM_SETCONTROLTEXT, IDOK, NativeUInt(PChar('MyCaption')));
end;

The dialog is changing the button text when you select a folder to 'Open', when the selection is not a folder, your custom caption is restored. 当您选择文件夹为“打开”时,对话框正在更改按钮文本,当选择不是文件夹时,您的自定义标题将被恢复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM