簡體   English   中英

將圖像添加到 Inno Setup 卸載程序背景

[英]Adding image to Inno Setup uninstaller 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;

但是如何為卸載頁面執行此操作? 以上僅適用於安裝頁面。

好吧,實際上由於卸載表單的結構與安裝向導相同,因此卸載代碼幾乎相同。 您只需將代碼移動到InitializeUninstallProgressForm並使用UninstallProgressForm而不是WizardForm 並且顯然刪除了對卸載表單上不存在的控件的引用。

要在卸載程序中使用自定義圖像,請參閱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