简体   繁体   English

将图像添加到 Inno Setup 卸载程序背景

[英]Adding image to Inno Setup uninstaller background

This is the code to fill the background of the Inno Setup with an image, and hide the inner and outer panels, taken from Inno Setup - Image as installer background :这是用图像填充 Inno Setup 的背景并隐藏内部和外部面板的代码,取自Inno Setup - Image as installer background

procedure InitializeWizard();
var
  BackImage: TBitmapImage;
begin
  { Hide top panel }
  WizardForm.MainPanel.Visible := False;

  { Adjust "select dir" page controls for a stretched inner page size }
  WizardForm.DirEdit.Left :=
    WizardForm.DirEdit.Left + WizardForm.InnerNotebook.Left;
  WizardForm.DirEdit.Top := WizardForm.DirEdit.Top + WizardForm.InnerNotebook.Top;
  WizardForm.DirBrowseButton.Left :=
    WizardForm.DirBrowseButton.Left + WizardForm.InnerNotebook.Left;
  WizardForm.DirBrowseButton.Top :=
    WizardForm.DirBrowseButton.Top + WizardForm.InnerNotebook.Top;

  { Hide non-transparent labels }    
  WizardForm.DiskSpaceLabel.Visible := False;
  WizardForm.SelectDirBrowseLabel.Visible := False;
  WizardForm.SelectDirLabel.Visible := False;

  { Stretch the outer page across whole form }
  WizardForm.OuterNotebook.Width := WizardForm.ClientWidth;
  WizardForm.OuterNotebook.Height := WizardForm.ClientHeight;

  { Stretch the inner page across whole outer page }
  WizardForm.InnerNotebook.Left := 0;
  WizardForm.InnerNotebook.Top := 0;
  WizardForm.InnerNotebook.Width := WizardForm.OuterNotebook.ClientWidth;
  WizardForm.InnerNotebook.Height := WizardForm.OuterNotebook.ClientHeight;

  { Put buttons on top of the page (image) }
  WizardForm.BackButton.BringToFront()
  WizardForm.NextButton.BringToFront();
  WizardForm.CancelButton.BringToFront();

  { Add a background image }    
  BackImage := TBitmapImage.Create(WizardForm);
  BackImage.Parent := WizardForm.SelectDirPage;
  BackImage.Top := 0;
  BackImage.Left := 0;  
  { ... }
  BackImage.Bitmap.LoadFromFile(...);
end;

But how to do this for uninstall pages?但是如何为卸载页面执行此操作? The above works only for the install pages.以上仅适用于安装页面。

Well, actually as the uninstall form is structured the same way as the install wizard, the code for uninstall will be pretty much the same.好吧,实际上由于卸载表单的结构与安装向导相同,因此卸载代码几乎相同。 You just need to move the code to InitializeUninstallProgressForm and use UninstallProgressForm instead of WizardForm .您只需将代码移动到InitializeUninstallProgressForm并使用UninstallProgressForm而不是WizardForm And obviously remove the references to controls that do not exist on the uninstall form.并且显然删除了对卸载表单上不存在的控件的引用。

For using custom images in uninstaller, see Inno Setup: Reading a file from installer during uninstallation .要在卸载程序中使用自定义图像,请参阅Inno Setup:在卸载期间从安装程序读取文件

procedure InitializeUninstallProgressForm();
var
  BackImage: TBitmapImage;
begin
  { Hide top panel }
  UninstallProgressForm.MainPanel.Visible := False;

  { Stretch the outer page across whole form }
  UninstallProgressForm.OuterNotebook.Width :=
    UninstallProgressForm.ClientWidth;
  UninstallProgressForm.OuterNotebook.Height :=
    UninstallProgressForm.ClientHeight;

  { Stretch the inner page across whole outer page }
  UninstallProgressForm.InnerNotebook.Left := 0;
  UninstallProgressForm.InnerNotebook.Top := 0;
  UninstallProgressForm.InnerNotebook.Width :=
    UninstallProgressForm.OuterNotebook.ClientWidth;
  UninstallProgressForm.InnerNotebook.Height :=
    UninstallProgressForm.OuterNotebook.ClientHeight;

  { Put buttons on top of the page (image) }
  UninstallProgressForm.CancelButton.BringToFront();

  { Add a background image }    
  BackImage := TBitmapImage.Create(UninstallProgressForm);
  BackImage.Parent := UninstallProgressForm.InstallingPage;
  BackImage.Top := 0;
  BackImage.Left := 0;  
  BackImage.SetBounds(
    0, 0, UninstallProgressForm.InnerPage.ClientWidth,
    UninstallProgressForm.InnerPage.ClientHeight);
  BackImage.Stretch := True;
  BackImage.AutoSize := False
  BackImage.Anchors := [akLeft, akTop, akRight, akBottom];
  { ... }
  BackImage.Bitmap.LoadFromFile(...);
end;

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM