您可以创建一个类似于“完成"页面的自定义页面吗? [英] Can you create a custom page that looks like the Finish page?

查看:26
本文介绍了您可以创建一个类似于“完成"页面的自定义页面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以创建一个类似于完成"页面的自定义页面吗?

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'
); 

此自定义页面,

需要看起来像这样

之所以这样,是因为有时用户再次运行安装程序时,他们将能够选择几个选项.根据选项,安装程序需要对已安装程序使用的设置进行少量更改,而无需通过重新安装来覆盖文件.因此,用户应在更改后获得完成"对话框.

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. 在自定义页面上重新创建 FinishedPage 控件.

进入页面时,您需要调整 WizardForm.InnerNotebook 的大小以覆盖整个向导窗口(底部按钮区域除外)并隐藏页面标题控件.

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;

有一些限制:

  • 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.

相关问题:

  • 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?

这篇关于您可以创建一个类似于“完成"页面的自定义页面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆