The official Inno Setup code to change Next button

2019-08-14 14:50发布

I'm using the code from: http://www.jrsoftware.org/ishelp/index.php?topic=setup_disablereadypage

It should change the Next button caption to Install when the "Ready" page is disabled using DisableReadyPage directive.

[Setup]
DisableReadyPage=yes

[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectProgramGroup then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
  else
    WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;

But it does not change Next button caption.

enter image description here

标签: inno-setup
1条回答
smile是对你的礼貌
2楼-- · 2019-08-14 15:41

As the description of the code says:

For example, if the new last pre-installation wizard page is the Select Program Group page: ...

In your case the last pre-installation page is not Select Program Group page. It's the Select Destination Location page. Probably because you have DisableProgramGroupPage set to no, or you have set it to auto and you are upgrading (the application is installed already).

If you have the DisableProgramGroupPage set to no, the solution is simple, as the Select Destination Location page is always the last. Just replace the wpSelectProgramGroup with wpSelectDir.

[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectDir then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
  else
    WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;

With auto (the default), you do not get any of Select Program Group and Select Destination Location on upgrade, but you get the Ready to Install even with DisableProgramGroupPage (as there would not be any other page before installation). You can use that fact to use Install both for Select Program Group page (for fresh installs) and Ready to Install (for upgrades).

Another issue with their code is that you should get a Finish button on the "Finished" page (wpFinished). What their code does not care for.

The complete solution is:

procedure CurPageChanged(CurPageID: Integer);
begin
  // On fresh install the last pre-install page is "Select Program Group".
  // On upgrade the last pre-install page is "Read to Install"
  // (forced even with DisableReadyPage)
  if (CurPageID = wpSelectProgramGroup) or (CurPageID = wpReady) then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
  // On the Finished page, use "Finish" caption.
  else if (CurPageID = wpFinished) then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish)
  // On all other pages, use "Next" caption.
  else
    WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;

Had you have other pages, like Tasks page, you would have to alter the code accordingly.

查看更多
登录 后发表回答