0

Is it possible to change WizardImageFile during runtime? I want this picture to change on some condition. Couldn't change it in code, {code:GetGraphics} is also cannot be used in WizardImageFile parameter. Has anyone changed it succesfully at runtime? Maybe there is another way to set WizardForm.WizardBitmapImage's picture?

Sega-Zero
  • 3,034
  • 2
  • 22
  • 46

1 Answers1

4

The following script shows how to conditionally display one of two images depending on if it's morning or afternoon. Those images are included in the setup just for this purpose and are extracted to a temporary directory used by the setup, when the wizard form is initialized. Since you were attempting to use a code section to change the WizardImageFile directive value (which is not possible), you are going to work with the WizardBitmapImage image of the WizardForm:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "Image1.bmp"; Flags: dontcopy
Source: "Image2.bmp"; Flags: dontcopy

[Code]
procedure InitializeWizard;
var
  FileName: string;
begin
  if StrToInt(GetDateTimeString('h', #0, #0)) < 12 then
    FileName := 'Image1.bmp'
  else
    FileName := 'Image2.bmp';

  ExtractTemporaryFile(FileName);
  WizardForm.WizardBitmapImage.Bitmap.LoadFromFile(
    ExpandConstant('{tmp}\' + FileName));
end;
TLama
  • 75,147
  • 17
  • 214
  • 392
  • this helps only when you need to set picture once, i need to change it from one to another during installation – Sega-Zero Feb 23 '13 at 12:36
  • Sorry, but the image `WizardImageFile` directive affects just the image on the left side of the welcome page, doesn't it ? Which image (ideally shown on a screenshot) do you want to change then ? Anyway, there's no event fired during installation progress, so this is not possible without using some extension (maybe you want [something like this](http://stackoverflow.com/q/10130184/960757), hard to say). – TLama Feb 23 '13 at 12:41
  • not only welcomepage, but finished page too. I couldn't create custom page that could look like finisehd page, so i do Result := False in NextButtonClick and then change the content of finished page as if it were next page. But i can't change the left picture – Sega-Zero Feb 23 '13 at 13:19
  • The image on the finished page is the `WizardForm.WizardBitmapImage2`, so you can simply move the code from my post to the `NextButtonClick` event method and modify the image control name. – TLama Feb 23 '13 at 13:21
  • Damn... Thanks a lot, i was changing the wrong BitmapImage >_ – Sega-Zero Feb 23 '13 at 14:11