Reputation: 280
I have a TSavetextfiledialog where the user selects a filename for saving, but the save doesn't happen immediately. Therefore I would like the save button to display "select" rather than "save". Can the caption of the button be changed?
Upvotes: 1
Views: 1225
Reputation: 54802
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. For IDs of other items, see documentation on Explorer-Style Control Identifiers. Here is calling it in the OnShow
event handler:
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.
Upvotes: 3