你能创建一个看起来像完成页面的自定义页面吗?

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

你能创建一个看起来像完成页面的自定义页面吗?

这是自定义页面的代码,

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

这个自定义页面,

需要看起来像这样,

这是因为,有时当用户再次运行安装程序时,他们将能够 select 几个选项。根据选项,安装程序需要对已安装程序使用的设置进行少量更改,而不会通过重新安装覆盖文件。所以用户应该在更改后看到完成对话框。

  1. 在自定义页面上重新创建 FinishedPage 控件。

  2. 进入页面时,需要调整大小WizardForm.InnerNotebook以覆盖整个向导window(底部按钮区域除外)并隐藏页眉控件。

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;


有一些限制:

  • 当向导调整大小时(使用 WizardResizable=yes),代码无法正确处理图像调整大小 – 不过很容易修复。
  • 该解决方案不希望在显示此假完成页面后显示任何页面。 IE。没有 Back 按钮,预计 Finish 按钮将用于终止安装程序。毕竟,这是
  • 的后续问题

虽然要避免所有这些黑客攻击,但请考虑让安装正常进行,但不要更改任何内容。最终可能会更容易实现。


相关问题:

  • – 通过在向导的整个上部覆盖控件来解决问题的替代实现 window,hiding/showing 根据需要。
  • How to hide the main panel and show an image over the whole page?