我正在尝试覆盖wpFinished页面上的Next / Cancel按钮 - NextButton应该显示下载的文件并退出安装程序 - 它正常工作但是CancelButton什么都不做 - 它应该用标准确认关闭安装程序。我想知道标准的inno事件是否可行,或者我需要编写自己的代码来退出应用程序并显示确认信息?
function NextButtonClick(CurPage: Integer): Boolean;
begin
if CurPage = wpFinished then begin
ShowDownloadedFile();
end;
Result := True;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpFinished then begin
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall);
WizardForm.CancelButton.Caption := SetupMessage(msgButtonFinish);
WizardForm.CancelButton.Visible := True;
end;
end;
答案 0 :(得分:2)
就是这样,但不要在家里做孩子: - )
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
procedure ExitProcess(uExitCode: UINT);
external 'ExitProcess@kernel32.dll stdcall';
function NextButtonClick(CurPage: Integer): Boolean;
begin
Result := True;
// if the fake Finish button was clicked...
if CurPage = wpFinished then
MsgBox('Welcome to the next installation!', mbInformation, MB_OK);
end;
procedure CancelButtonClickFinishedPage(Sender: TObject);
begin
// display the "Exit Setup ?" message box and if the user selects "Yes",
// then exit the process; it is currently the only way how to exit setup
// process manually
if ExitSetupMsgBox then
ExitProcess(0);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpFinished then
begin
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall);
WizardForm.CancelButton.Caption := SetupMessage(msgButtonFinish);
WizardForm.CancelButton.Visible := True;
// bind your own OnClick event for the Cancel button; the original one
// is already disconnected at this stage
WizardForm.CancelButton.OnClick := @CancelButtonClickFinishedPage;
end;
end;
答案 1 :(得分:1)
正在尝试执行的操作的正确替代方法是包含[Run]
条目,如下所示:
[Run]
Filename: {app}\yourfile.exe; Description: Run my application; Flags: postinstall nowait
这会在wpFinished
页面上显示一个复选框,让他们可以选择是否运行该应用。