2

我想用包含安装进度条的自定义面板替换我们显示下一步、后退按钮的底部面板。安装完成后,页面应自动重定向到下一页。下面是样机图像,我想如何制作这个页面。

在此处输入图像描述

4

1 回答 1

6

这是脚本,还包括您的主面板标题previous question。将其保存到您的..\InnoSetup\Examples\文件夹以及您需要转换为 BMP 文件的以下图像,因为我找不到任何不会将图像转换为 PNG 或 JPG 格式的受信任文件共享站点:

  • this one转换为 BMP 并另存为Logo.bmp
  • this one转换为 BMP 并另存为InstallBackground.bmp

这是脚本(您应该commented version首先遵循此脚本):

[Setup]
AppName=ERPBO
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output
WizardSmallImageFile=Logo.bmp

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "InstallBackground.bmp"; Flags: dontcopy

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Run]
Filename: "{app}\MyProg.chm"; Check: JustBlockTheInstallPage

[Messages]
SetupWindowTitle=Installere - %1
WizardInstalling=Installasjon pågår...

[Code]
function JustBlockTheInstallPage: Boolean;
begin
  Result := False;  
  WizardForm.StatusLabel.Caption := 'Pakker ut filer...';
  WizardForm.FilenameLabel.Caption :='C:\dnpr\Crystal reports setup\WindowShoppingNet.msi';
  MsgBox('Message just to see the install page :-)', mbInformation, MB_OK);
end;

var
  InnerNotebookBounds: TRect;
  OuterNotebookBounds: TRect;
  InstallBottomPanel: TPanel;
  InstallBackground: TBitmapImage;

function Rect(const ALeft, ATop, ARight, ABottom: Integer): TRect;
begin
  Result.Left := ALeft;
  Result.Top := ATop;
  Result.Bottom := ABottom;
  Result.Right := ARight;
end;

function GetBoundsRect(AControl: TControl): TRect;
begin
  Result.Left := AControl.Left;
  Result.Top := AControl.Top;
  Result.Right := AControl.Left + AControl.Width;
  Result.Bottom := AControl.Top + AControl.Height;
end;

procedure SetBoundsRect(AControl: TControl; const ARect: TRect);
begin
  AControl.Left := ARect.Left;
  AControl.Top := ARect.Top;
  AControl.Width := ARect.Right - ARect.Left
  AControl.Height := ARect.Bottom - ARect.Top;
end;

procedure CenterHorizontally(ASource, ATarget: TControl);
begin
  ATarget.Left := (ASource.Width - ATarget.Width) div 2;
end;

procedure CenterVertically(ASource, ATarget: TControl);
begin
  ATarget.Top := (ASource.Height - ATarget.Height) div 2;  
end;

procedure InitializeWizard;
begin              
  WizardForm.PageDescriptionLabel.Visible := False;

  WizardForm.PageNameLabel.Font.Size := 18;
  WizardForm.PageNameLabel.Font.Name := 'Comic Sans MS';
  WizardForm.PageNameLabel.AutoSize := True;
  WizardForm.PageNameLabel.Left := 18;
  CenterVertically(WizardForm.MainPanel, WizardForm.PageNameLabel); 

  WizardForm.WizardSmallBitmapImage.AutoSize := True;
  WizardForm.WizardSmallBitmapImage.Left := WizardForm.ClientWidth - WizardForm.WizardSmallBitmapImage.Width - 18;
  CenterVertically(WizardForm.MainPanel, WizardForm.WizardSmallBitmapImage); 

  WizardForm.InstallingPage.Color := clWhite;  

  InstallBottomPanel := TPanel.Create(WizardForm);
  InstallBottomPanel.Parent := WizardForm.InstallingPage;
  InstallBottomPanel.BevelOuter := bvNone;
  InstallBottomPanel.Align := alBottom;
  InstallBottomPanel.Caption := '';
  InstallBottomPanel.Color := $00C7CFD3;
  InstallBottomPanel.Height := 79;
  InstallBottomPanel.ParentBackground := False;

  ExtractTemporaryFile('InstallBackground.bmp');

  InstallBackground := TBitmapImage.Create(WizardForm);
  InstallBackground.Parent := WizardForm.InstallingPage;
  InstallBackground.AutoSize := True;
  InstallBackground.Bitmap.LoadFromFile(ExpandConstant('{tmp}\InstallBackground.bmp'));

  WizardForm.StatusLabel.Parent := InstallBottomPanel;
  WizardForm.StatusLabel.Left := 8;
  WizardForm.StatusLabel.Top := 8;
  WizardForm.FilenameLabel.Parent := InstallBottomPanel;
  WizardForm.FilenameLabel.Left := 8;
  WizardForm.FilenameLabel.Top := WizardForm.StatusLabel.Top + 16;
  WizardForm.ProgressGauge.Parent := InstallBottomPanel;
  WizardForm.ProgressGauge.Left := 8;
  WizardForm.ProgressGauge.Top := WizardForm.FilenameLabel.Top + 26;

  InnerNotebookBounds := GetBoundsRect(WizardForm.InnerNotebook);
  OuterNotebookBounds := GetBoundsRect(WizardForm.OuterNotebook);
end;

procedure CurPageChanged(CurPageID: Integer);  
begin
  if CurPageID = wpInstalling then
  begin
    SetBoundsRect(WizardForm.OuterNotebook, Rect(OuterNotebookBounds.Left, 
      OuterNotebookBounds.Top, OuterNotebookBounds.Right, WizardForm.ClientHeight));
    SetBoundsRect(WizardForm.InnerNotebook, Rect(OuterNotebookBounds.Left,
      WizardForm.Bevel1.Top + WizardForm.Bevel1.Height, OuterNotebookBounds.Right, 
      WizardForm.ClientHeight));          

    CenterHorizontally(WizardForm.InstallingPage, InstallBackground);
    InstallBackground.Top := InstallBottomPanel.Top - InstallBackground.Height;
    WizardForm.ProgressGauge.Width := InstallBottomPanel.Width - 16;
  end
  else
  begin
    SetBoundsRect(WizardForm.OuterNotebook, OuterNotebookBounds);
    SetBoundsRect(WizardForm.InnerNotebook, InnerNotebookBounds);
  end;
end;

结果是安装页面的样子(是的,我使用了 Comic Sans :-)

在此处输入图像描述

于 2012-06-27T02:55:53.397 回答