Search code examples
inno-setupwizardpascalscript

Inno Setup customize FinishedLabel with Pascal Script


My goal with Inno Setup 6.x is to customize the FinishedLabel text in code, i.e., Pascal Script. The reason why I'm using Pascal Script is that I want to only customize/change the label if IsAdminMode() is true. How can I do that?

The following two approaches do not work:

  1. Use a scripted constant:

    [Messages]
    FinishedLabel={code:GetFinishedLabel}
    
    [Code]
    function GetFinishedLabel(Param: String): String;
    begin
      Result := 'BLA';
    end;
    

    This shows "{code:GetFinishedLabel}" rather than "BLA".

  2. Customize the wizard in InitializeWizard.

    Complete (failing) example:

    [Code]
    procedure InitializeWizard();
    begin
      WizardForm.FinishedLabel.Caption := 'BLA';
    end;
    

    The FinishLabel still shows the original text from Default.isl

Any ideas?


Solution

  • The FinishedLabel is updated at the end of the installation according to various factors. So your value set in InitializeWizard is overridden. You have to set your custom message later, such as in CurPageChanged(wpFinished):

    procedure CurPageChanged(CurPageID: Integer);
    begin
      if CurPageID = wpFinished then
      begin
        WizardForm.FinishedLabel.Caption := 'BLA';
      end;
    end;
    

    You might consider to improve the code to do what Inno Setup would do, like:

    • Taking into account, if restart is needed (FinishedRestartLabel);
    • Taking into account, if icons were created (FinishedLabel vs. FinishedLabelNoIcons);
    • Adjusting the label height to fit the message;
    • Shifting RunList position according to the message height.