Inno Setup personaliza FinishedLabel con Pascal Script

Oct 06 2020

Mi objetivo con Inno Setup 6.x es personalizar el FinishedLabeltexto en código, es decir, Pascal Script. La razón por la que estoy usando Pascal Script es que solo quiero personalizar / cambiar la etiqueta si IsAdminMode()es verdadera. ¿Cómo puedo hacer eso?

Los dos enfoques siguientes no funcionan:

  1. Utilice una constante con script:

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

    Esto muestra "{código: GetFinishedLabel}" en lugar de "BLA".

  2. Personaliza el asistente en formato 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?

Respuestas

2 pimpo Oct 06 2020 at 18:25

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.