inno-setup

Change messages/texts at runtime (Inno Setup)


In an innosetup script it is possible to define messages like this:

[Messages]
WelcomeLabel2=This wizard will update [name] to version [name/ver]

Now I would like to change this message at runtime, like this:

procedure InitializeWizard;
begin
    //this doesn't work        
    WelcomeLabel2=NEW MESSAGE 
end;

What is the correct way to do this? I want to dynamically change the contents of the welcome page to display whether the setup is performing a new installation or update. Based on the existence of some executables in the installation directory.


Solution

  • One way;

    [Languages]
    Name: "en"; MessagesFile: "compiler:Default.isl"
    
    [CustomMessages]
    en.WelcomeLabel2_ForInstall=install {#SetupSetting("AppName")}, {#SetupSetting("AppVersion")}
    en.WelcomeLabel2_ForUpdate=update {#SetupSetting("AppName")} to {#SetupSetting("AppVersion")}
    
    [code]
    procedure InitializeWizard(); 
    var
      message: string;
    begin 
        //some logic
        message := 'WelcomeLabel2_ForUpdate';
        WizardForm.WelcomeLabel2.Caption := CustomMessage(message);
    end;
    
    procedure CurPageChanged(CurPageID: Integer);
    begin
      case CurPageID of
          wpFinished : WizardForm.FinishedLabel.Caption := 'bla bla';
      end;
    end;