Can you create a custom page that looks like the Finish page?

别来无恙 提交于 2021-02-04 21:01:51

问题


Can you create a custom page that looks like the Finish page?

This is the code for custom page,

UserPage2 := CreateCustomPage(
  UserPage1.ID,
  'Title',    
  'Details'
); 

This custom page,

Needs to look like this,

The reason for this is because, sometimes when the user runs the installer again they will be able to select few options. Based on the options the installer needs to make few changes to the settings used by the installed program without overwriting the files by reinstalling. So the user should get the Finish dialog after the changes.


回答1:


  1. Recreate the FinishedPage controls on your custom page.

  2. When entering the page, you need to resize WizardForm.InnerNotebook to cover whole wizard window (except for the bottom button area) and hide the page header controls.

var
  FakeFinishedPage: TWizardPage;
  FakeFinishedBitmapImage: TBitmapImage;
  FakeFinishedLabel: TNewStaticText;
  FakeFinishedHeadingLabel: TNewStaticText;

procedure CopyBounds(Dest, Source: TControl);
begin
  Dest.Left := Source.Left;
  Dest.Top := Source.Top;
  Dest.Width := Source.Width;
  Dest.Height := Source.Height;
end;

procedure FakeFinishedPageActivate(Sender: TWizardPage);
begin
  WizardForm.Bevel1.Visible := False;
  WizardForm.MainPanel.Visible := False;
  WizardForm.InnerNotebook.Left := 0;
  WizardForm.InnerNotebook.Top := 0;
  WizardForm.InnerNotebook.Width := WizardForm.OuterNotebook.ClientWidth;
  WizardForm.InnerNotebook.Height := WizardForm.OuterNotebook.ClientHeight;

  // With WizardStyle=modern and/or WizardResizable=yes,
  // we cannot copy the sizes in InitializeWizard as they are not final yet.
  CopyBounds(FakeFinishedBitmapImage, WizardForm.WizardBitmapImage2);
  FakeFinishedBitmapImage.Anchors := WizardForm.WizardBitmapImage2.Anchors;

  CopyBounds(FakeFinishedLabel, WizardForm.FinishedLabel);
  FakeFinishedLabel.Anchors := WizardForm.FinishedLabel.Anchors;
  CopyBounds(FakeFinishedHeadingLabel, WizardForm.FinishedHeadingLabel);
  FakeFinishedHeadingLabel.Anchors := WizardForm.FinishedHeadingLabel.Anchors;

  WizardForm.BackButton.Visible := False;
  WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish);
end;

procedure CopyLabel(Dest, Source: TNewStaticText);
begin
  Dest.AutoSize := Source.AutoSize;
  Dest.Font := Source.Font;
  Dest.ShowAccelChar := Source.ShowAccelChar;
  Dest.WordWrap := Source.WordWrap;
end;

procedure InitializeWizard();
var
  S: string;
begin
  // ...

  FakeFinishedPage := CreateCustomPage(UserPage1.ID, '', ''); 
  FakeFinishedPage.OnActivate := @FakeFinishedPageActivate;

  FakeFinishedBitmapImage := TBitmapImage.Create(WizardForm);
  FakeFinishedBitmapImage.Parent := FakeFinishedPage.Surface;
  FakeFinishedBitmapImage.BackColor := WizardForm.WizardBitmapImage2.BackColor;
  FakeFinishedBitmapImage.Bitmap := WizardForm.WizardBitmapImage2.Bitmap;
  FakeFinishedBitmapImage.Stretch := WizardForm.WizardBitmapImage2.Stretch;

  FakeFinishedLabel := TNewStaticText.Create(WizardForm);
  FakeFinishedLabel.Parent := FakeFinishedPage.Surface;
  CopyLabel(FakeFinishedLabel, WizardForm.FinishedLabel);
  S := SetupMessage(msgFinishedLabelNoIcons) + #13#13 + SetupMessage(msgClickFinish);
  StringChangeEx(S, '[name]', 'My Program', True);
  FakeFinishedLabel.Caption := S;

  FakeFinishedHeadingLabel := TNewStaticText.Create(WizardForm);
  FakeFinishedHeadingLabel.Parent := FakeFinishedPage.Surface;
  CopyLabel(FakeFinishedHeadingLabel, WizardForm.FinishedHeadingLabel);
  S := SetupMessage(msgFinishedHeadingLabel);
  StringChangeEx(S, '[name]', 'My Program', True);
  FakeFinishedHeadingLabel.Caption := S;
end;


There are some limitations:

  • The code does not handle correctly image resizes, when the wizard resizes (with WizardResizable=yes) – it's easy to fix though.
  • The solution does not expect that any page will be shown after this fake finish pages shows. I.e. there's no Back button and it's expected that the Finish button is implement to kill the intallater. After all, this is a follow up question to Conditionally skip to a custom page at the end of the Inno Setup installation wizard without installing?

Though to avoid all these hacks, consider allowing the installation to proceed normally, but without changing anything. It might be easier to implement in the end.


Related questions:

  • Image covering whole page in Inno Setup – An alternative implementation that solves the problem by overlaying a control over whole upper part of the wizard window, hiding/showing it as needed.
  • Custom Welcome and Finished page with stretched image in Inno Setup
  • How to hide the main panel and show an image over the whole page?


来源:https://stackoverflow.com/questions/65619515/can-you-create-a-custom-page-that-looks-like-the-finish-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!