Inno Setup 将 CreateInputFilePage 行为从打开更改为保存

Inno Setup change the CreateInputFilePage behaviour from Open to Save

我正在使用 CreateInputFilePage 函数创建一个带有输入字段和允许 select 路径和文件离子的浏览按钮的页面。问题是我不想select一个文件打开,我想指定一个文件保存到。指定不存在的路径和文件时的默认行为是提示

File not found. Check the file name and try again.

不幸的是,这不是指定要保存到的文件时所需的行为。在这种情况下需要提示

File does not exist. Create the file?

或类似的东西并允许select选择的路径和文件。

理想情况下,浏览对话框中的打开按钮也应更改为 "Save"。

是否可以按照描述修改此行为并更改按钮文本?如果是这样,如何做到这一点?

使用TInputFileWizardPage.IsSaveButton property.

要执行确认,处理 TWizardPage.OnNextButtonClick 事件。

var
  FileIndex: Integer;

function InputFileCheck(Page: TWizardPage): Boolean;
var
  Path: string;
begin
  Result := True;
  Path := Trim(TInputFileWizardPage(Page).Values[FileIndex]);
  if Length(Path) = 0 then
  begin
    MsgBox('No file specified.', mbError, MB_OK);
    Result := False;
  end
    else
  if not FileExists(Path) then
  begin
    Result :=
      MsgBox('File does not exist. Create the file?', mbConfirmation, MB_YESNO) = IDYES;
  end;
end;

procedure InitializeWizard;
var
  Page: TInputFileWizardPage;
begin
  Page := CreateInputFilePage('...', '...', '...', '...');
  Page.OnNextButtonClick := @InputFileCheck;

  FileIndex := Page.Add('...', '...', '...');
  Page.IsSaveButton[FileIndex] := True;
  ...
end;