5

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.

koen
  • 1,037
  • 3
  • 19
  • 27

2 Answers2

7

One way;

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"

[CustomMessages]
en.WelcomeLabel2_ForInstall=intstall {#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;
Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • I would like to do this too with WizardForm.FinishedLabelNoIcons.Caption, but the Inno Setup compiler errors with "Unknown identifier". – koen Feb 14 '12 at 14:40
  • Updated above, seems you can get at that via `WizardForm.FinishedLabel` (but not in `InitializeWizard`) – Alex K. Feb 14 '12 at 15:01
  • Thanks Alex. I have to change so many messages that it might be a better idea to dynamically change the MessagesFile in the code section. Do you know how to do that? – koen Feb 14 '12 at 21:10
  • I don't think you can, they are compiled into the setup and used automatically based on language – Alex K. Feb 15 '12 at 10:58
0

Hm, this won't work, I think. One way could be to create two pages for the installer - one with the layout for the installation process and one with the layout for the update process. Then, change the page sequence in a way that you manually decide which one to show.

An example for integrating a new page into the process can be found in my answer here.

Community
  • 1
  • 1
Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
  • Would it be possible to create a new page based on the welcome page? Or would I have to recreate the welcome page? – koen Feb 14 '12 at 12:34
  • Event though Alex K.'s solution is correct: I don't think there's something like "page inheritance" - you'd have to create the pages from scratch. – Thorsten Dittmar Feb 14 '12 at 15:17