How to remove the bottom panel in inno set up..and

2019-05-29 02:03发布

问题:

i want to replace the bottom panel where we show Next,Back buttons with a custom panel which includes the installation progress bar..once the installation is completed,then page should automatically redirected to next page. Below is mockup image,how i want to make this page.

回答1:

Here is the script including also the main panel header from your previous question as well. Save it into your ..\InnoSetup\Examples\ folder as well as the following images which you need to convert to BMP files since I couldn't find any trusted file sharing site which wouldn't convert the images to PNG or JPG format:

  • this one convert to BMP and save as Logo.bmp
  • this one convert to BMP and save as InstallBackground.bmp

Here is the script (you should follow the commented version of this script first):

[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;

And the result how the installation page looks like (and yes, I have used Comic Sans :-)