Pascal Scripting: WizardSetBackImage

Prototype:

procedure WizardSetBackImage(const BackImages: TArrayOfGraphic; const Stretch, Center: Boolean; const Opacity: Byte);

Description:

Sets a wizard background image. If multiple images are specified, the best-fitting one will be selected. If no images are specified, any existing background image is cleared and the other function parameters are ignored.

If Stretch is True, the image will be stretched or shrunk if the image is larger or smaller than required. If Stretch is False and Center is True, the image will be centered in the wizard window if it is smaller than required, and clipped if it is larger than required. Otherwise, the image will be positioned in the upper-left corner in its original size.

See WizardBackImageFile for information about the recommended image size(s).

Opacity specifies the opacity of the image, from 0 (fully transparent) to 255 (fully opaque, so non-transparent).

Raises an exception if a custom wizard background is not already active. Custom wizard backgrounds can be activated by using WizardBackColor, WizardBackColorDynamicDark, WizardBackImageFile, or WizardBackImageFileDynamicDark.

To display a single image for the entire duration of Setup, do not use this function. Instead, set WizardBackImageFile and optionally WizardBackImageFileDynamicDark.

Example:
[Setup]
WizardStyle=modern dynamic
WizardBackColor=#f3f3f3
WizardBackColorDynamicDark=#202020

[Files]
; Replace the DestDir parameters with the following if you do not need the
; images available during uninstall:
; Flags: dontcopy noencryption
Source: "MyImageNormal.png"; DestDir: "{app}"
Source: "MyImageLarge.png"; DestDir: "{app}"

[Code]
; Show an image on the install page only
<event('CurStepChanged')>
procedure CurStepChanged_UpdateBackImage(CurStep: TSetupStep);
var
  PngImages: TArrayOfGraphic; 
begin
  if CurStep = ssInstall then begin
    SetLength(PngImages, 2);
    PngImages[0] := TPngImage.Create;
    PngImages[1] := TPngImage.Create;
    try
      ExtractTemporaryFile('MyImageNormal.png');
      PngImages[0].LoadFromFile(ExpandConstant('{tmp}\MyImageNormal.png'));
      ExtractTemporaryFile('MyImageLarge.png');
      PngImages[1].LoadFromFile(ExpandConstant('{tmp}\MyImageLarge.png'));
      WizardSetBackImage(PngImages, True, True, 150);
    finally
      PngImages[1].Free;
      PngImages[0].Free;
    end;
  end else if CurStep = ssPostInstall then
    WizardSetBackImage([], True, True, 150);
end;

; Show an image during uninstall
<event('InitializeUninstallProgressForm')>
procedure InitializeUninstallProgressForm_UpdateBackImage;
var
  PngImages: TArrayOfGraphic;
begin
  try
    SetLength(PngImages, 2);
    PngImages[0] := TPngImage.Create;
    PngImages[1] := TPngImage.Create;
    try
      PngImages[0].LoadFromFile(ExpandConstant('{app}\MyImageNormal.png'));
      PngImages[1].LoadFromFile(ExpandConstant('{app}\MyImageLarge.png'));
      WizardSetBackImage(PngImages, True, False, 150);
    finally
      PngImages[1].Free;
      PngImages[0].Free;
    end;
  except
    LogFmt('Could not enable background image: %s', [GetExceptionMessage]);
  end;
end; 

; See CodeClasses.iss for another example.