有条件地跳到Inno Setup安装向导末尾的自定义页面而不安装吗? [英] Conditionally skip to a custom page at the end of the Inno Setup installation wizard without installing?
问题描述
下面的Inno Setup中的代码是用于检测 Next 按钮事件的代码,
In Inno Setup below is the code used to detect the Next button events,
function NextButtonClick(CurPageID: Integer): Boolean;
begin
case CurPageID of
wpLicense:
begin
//
end;
wpSelectDir:
begin
//
end;
wpSelectComponents:
begin
//
end;
wpReady:
begin
//
end;
wpFinished:
begin
//
end;
else
begin
///
end;
end;
end;
有一个自定义页面,该页面将在安装完成后和完成对话框之前显示.在用户选择的情况下,如何在 wpSelectDir
或 wpSelectComponents
上使安装程序转到该自定义页面而不进行安装?
There is custom page in place that will be shown after the installation is completed and before the finish dialog. At wpSelectDir
or wpSelectComponents
how can you make the installer go to this custom page without installing, when the user chooses so?
推荐答案
您不能在Inno Setup中跳过安装.但是您可以做的是动态更改自定义页面的位置以显示以下任一内容:
You cannot skip installation in Inno Setup. But what you can do is to dynamically change the placement of your custom page to show either:
- 安装后(例如,在
wpInfoAfter
之后),如果用户选择安装应用程序,或者 - 在安装之前(例如,紧接在
wpSelectDir
之后),如果没有.然后之后中止安装.
- after the installation (e.g. after
wpInfoAfter
), if the user chooses to install the application, or - before the installation (e.g. right after the
wpSelectDir
), if not. And abort the installation afterwards.
var
SkipInstallCheckbox: TNewCheckBox;
SomePage: TWizardPage;
procedure InitializeWizard();
begin
SkipInstallCheckbox := TNewCheckBox.Create(WizardForm.SelectDirPage);
SkipInstallCheckbox.Parent := WizardForm.SelectDirPage;
SkipInstallCheckbox.Top :=
WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + ScaleY(8);
SkipInstallCheckbox.Left := WizardForm.DirEdit.Left;
SkipInstallCheckbox.Caption := '&Skip installation';
// See https://stackoverflow.com/q/30469660/850848
SkipInstallCheckbox.Height := ScaleY(SkipInstallCheckbox.Height);
end;
procedure SomePageOnActivate(Sender: TWizardPage);
begin
if SkipInstallCheckbox.Checked then
begin
// When skipping the installation, this is the last page.
WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish);
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
AfterID: Integer;
begin
if CurPageID = wpSelectDir then
begin
if SkipInstallCheckbox.Checked then
AfterID := wpSelectDir
else
AfterID := wpInfoAfter;
// If user returned from the "skip" version of the page and
// re-enabled the installation, make sure we remove the "skip" version.
if Assigned(SomePage) then SomePage.Free;
SomePage := CreateCustomPage(AfterID, 'Some page', '');
SomePage.OnActivate := @SomePageOnActivate;
end;
Result := True;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := False;
// When skipping the installation, skip all pages after our custom page
// and before the installation.
if (PageID in [wpSelectComponents, wpSelectProgramGroup, wpSelectTasks, wpReady]) and
SkipInstallCheckbox.Checked then
begin
Result := True;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep = ssInstall) and SkipInstallCheckbox.Checked then
begin
// See https://stackoverflow.com/q/4438506/850848#39788977
Abort();
end;
end;
与您相关的一个问题可以改善此问题:您可以创建一个类似于完成"页面的自定义页面吗?
尽管要避免所有这些黑客攻击,但请考虑允许安装正常进行,但无需进行任何更改.最后可能更容易实现.
Though to avoid all these hacks, consider allowing the installation to proceed normally, but without changing anything. It might be easier to implement in the end.
这篇关于有条件地跳到Inno Setup安装向导末尾的自定义页面而不安装吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!