在 Inno Setup 中添加 4 个许可证页面

2024-04-20

我遵循了马丁的回答here https://stackoverflow.com/questions/34592002/how-to-create-two-licensefile-pages-in-inno-setup在我的 Inno Setup 安装程序中为 4 个许可证页面创建 UI。

代码如下所示(正在进行中..)

[Files]
Source: "license2_english.txt"; Flags: dontcopy
Source: "license3_english.txt"; Flags: dontcopy
Source: "license4_english.txt"; Flags: dontcopy

[Code]

var 
  SecondLicensePage: TOutputMsgMemoWizardPage;
  License2AcceptedRadio: TRadioButton;
  License2NotAcceptedRadio: TRadioButton;

  ThirdLicensePage: TOutputMsgMemoWizardPage;
  License3AcceptedRadio: TRadioButton;
  License3NotAcceptedRadio: TRadioButton;

  FourthLicensePage: TOutputMsgMemoWizardPage;
  License4AcceptedRadio: TRadioButton;
  License4NotAcceptedRadio: TRadioButton;

procedure CheckLicense2Accepted(Sender: TObject);
begin
  // Update Next button when user (un)accepts the license
  WizardForm.NextButton.Enabled := License2AcceptedRadio.Checked;
end;

procedure CheckLicense3Accepted(Sender: TObject);
begin
  // Update Next button when user (un)accepts the license
  WizardForm.NextButton.Enabled := License3AcceptedRadio.Checked;
end;

procedure CheckLicense4Accepted(Sender: TObject);
begin
  // Update Next button when user (un)accepts the license
  WizardForm.NextButton.Enabled := License4AcceptedRadio.Checked;
end;

function CloneLicenseRadioButtonL2(Source: TRadioButton): TRadioButton;
begin
  Result := TRadioButton.Create(WizardForm);
  Result.Parent := SecondLicensePage.Surface;
  Result.Caption := Source.Caption;
  Result.Left := Source.Left;
  Result.Top := Source.Top;
  Result.Width := Source.Width;
  Result.Height := Source.Height;
  Result.Anchors := Source.Anchors;
  Result.OnClick := @CheckLicense2Accepted;
end;

function CloneLicenseRadioButtonL3(Source: TRadioButton): TRadioButton;
begin
  Result := TRadioButton.Create(WizardForm);
  Result.Parent := ThirdLicensePage.Surface;
  Result.Caption := Source.Caption;
  Result.Left := Source.Left;
  Result.Top := Source.Top;
  Result.Width := Source.Width;
  Result.Height := Source.Height;
  Result.Anchors := Source.Anchors;
  Result.OnClick := @CheckLicense3Accepted;
end;

function CloneLicenseRadioButtonL4(Source: TRadioButton): TRadioButton;
begin
  Result := TRadioButton.Create(WizardForm);
  Result.Parent := FourthLicensePage.Surface;
  Result.Caption := Source.Caption;
  Result.Left := Source.Left;
  Result.Top := Source.Top;
  Result.Width := Source.Width;
  Result.Height := Source.Height;
  Result.Anchors := Source.Anchors;
  Result.OnClick := @CheckLicense4Accepted;
end;

//Create license wizards
procedure InitializeWizard();
var
  LicenseFileNameL2: string;
  LicenseFileNameL3: string;
  LicenseFilenameL4: string;
                 
  LicenseFilePathL2: string;
  LicenseFilePathL3: string;
  LicenseFilePathL4: string;
begin
  Log(Format('Temp :  %s', [ExpandConstant('{tmp}')]));
  // Create second license page, with the same labels as the original license page
  SecondLicensePage :=
    CreateOutputMsgMemoPage(
      wpLicense, SetupMessage(msgWizardLicense), SetupMessage(msgLicenseLabel),
      SetupMessage(msgLicenseLabel3), '');

  // Create third license page, with the same labels as the original license page
  ThirdLicensePage :=
    CreateOutputMsgMemoPage(
      wpLicense, SetupMessage(msgWizardLicense), SetupMessage(msgLicenseLabel),
      SetupMessage(msgLicenseLabel3), '');

  FourthLicensePage :=
    CreateOutputMsgMemoPage(
      wpLicense, SetupMessage(msgWizardLicense), SetupMessage(msgLicenseLabel),
      SetupMessage(msgLicenseLabel3), '');

  // Shrink license box to make space for radio buttons
  SecondLicensePage.RichEditViewer.Height := WizardForm.LicenseMemo.Height;
  ThirdLicensePage.RichEditViewer.Height  := WizardForm.LicenseMemo.Height;
  FourthLicensePage.RichEditViewer.Height := WizardForm.LicenseMemo.Height;

  // Load license
  // Loading ex-post, as Lines.LoadFromFile supports UTF-8,
  // contrary to LoadStringFromFile.
  LicenseFileNameL2 := 'license2_english.txt';
  LicenseFileNameL3 := 'license3_english.txt';
  LicenseFileNameL4 := 'license4_english.txt';

  LicenseFilePathL2 := ExpandConstant('{tmp}\' + LicenseFileNameL2);
  LicenseFilePathL3 := ExpandConstant('{tmp}\' + LicenseFileNameL3);
  LicenseFilePathL4 := ExpandConstant('{tmp}\' + LicenseFileNameL4);

  ExtractTemporaryFile(LicenseFileNameL2);
  ExtractTemporaryFile(LicenseFileNameL3);
  ExtractTemporaryFile(LicenseFileNameL4);

  SecondLicensePage.RichEditViewer.Lines.LoadFromFile(LicenseFilePathL2);
  ThirdLicensePage.RichEditViewer.Lines.LoadFromFile(LicenseFilePathL3);
  FourthLicensePage.RichEditViewer.Lines.LoadFromFile(LicenseFilePathL4);

  DeleteFile(LicenseFilePathL2);
  DeleteFile(LicenseFilePathL3);
  DeleteFile(LicenseFilePathL4);


  // Clone accept/do not accept radio buttons for the second license
  License2AcceptedRadio :=
    CloneLicenseRadioButtonL2(WizardForm.LicenseAcceptedRadio);
  License2NotAcceptedRadio :=
    CloneLicenseRadioButtonL2(WizardForm.LicenseNotAcceptedRadio);

  License3AcceptedRadio :=
    CloneLicenseRadioButtonL3(WizardForm.LicenseAcceptedRadio);
  License3NotAcceptedRadio :=
    CloneLicenseRadioButtonL3(WizardForm.LicenseNotAcceptedRadio);

  License4AcceptedRadio :=
    CloneLicenseRadioButtonL4(WizardForm.LicenseAcceptedRadio);
  License4NotAcceptedRadio :=
    CloneLicenseRadioButtonL4(WizardForm.LicenseNotAcceptedRadio);


  // Initially not accepted
  License2NotAcceptedRadio.Checked := True;
  License3NotAcceptedRadio.Checked := True;
  License4NotAcceptedRadio.Checked := True;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  // Update Next button when user gets to second license page
  if CurPageID = SecondLicensePage.ID then
  begin
    CheckLicense2Accepted(nil);
  end;
end;

procedure CurPageChangedL3(CurPageID: Integer);
begin
  // Update Next button when user gets to second license page
  if CurPageID = ThirdLicensePage.ID then
  begin
    CheckLicense3Accepted(nil);
  end;
end;

procedure CurPageChangedL4(CurPageID: Integer);
begin
  // Update Next button when user gets to second license page
  if CurPageID = FourthLicensePage.ID then
  begin
    CheckLicense4Accepted(nil);
  end;
end;

通过这段代码,我看到以下问题:

  1. 许可证 4 页面出现在许可证 2 和 3 之前
  2. 在第 2 页中,单选按钮最初被初始化为“我不接受”。在这种情况下,“下一步”按钮被启用,用户可以移至下一个屏幕。

图像显示即使选择“我不接受”,“下一步”按钮仍处于启用状态。另外,许可证 4 会先于许可证 2 出现

我知道当我试图扩展马丁的答案以涵盖更多许可证时,我在某个地方犯了一个基本错误,但我还无法弄清楚。

如果有人有解决/调试此问题的想法,请告诉我。

谢谢! A


我不会尝试解决您的问题,因为您将所有代码复制三次的方式非常低效且难以维护。相反,需要考虑创建额外的许可证页面。像这样的东西:

[Setup]
LicenseFile=license1.txt

[Files]
Source: "license2.txt"; Flags: dontcopy
Source: "license3.txt"; Flags: dontcopy
Source: "license4.txt"; Flags: dontcopy
[Code]

var
  LicenseAcceptedRadioButtons: array of TRadioButton;

procedure CheckLicenseAccepted(Sender: TObject);
begin
  // Update Next button when user (un)accepts the license
  WizardForm.NextButton.Enabled :=
    LicenseAcceptedRadioButtons[TComponent(Sender).Tag].Checked;
end;

procedure LicensePageActivate(Sender: TWizardPage);
begin
  // Update Next button when user gets to second license page
  CheckLicenseAccepted(LicenseAcceptedRadioButtons[Sender.Tag]);
end;

function CloneLicenseRadioButton(
  Page: TWizardPage; Source: TRadioButton): TRadioButton;
begin
  Result := TRadioButton.Create(WizardForm);
  Result.Parent := Page.Surface;
  Result.Caption := Source.Caption;
  Result.Left := Source.Left;
  Result.Top := Source.Top;
  Result.Width := Source.Width;
  Result.Height := Source.Height;
  // Needed for WizardStyle=modern / WizardResizable=yes
  Result.Anchors := Source.Anchors;
  Result.OnClick := @CheckLicenseAccepted;
  Result.Tag := Page.Tag;
end;

var
  LicenseAfterPage: Integer;

procedure AddLicensePage(LicenseFileName: string);
var
  Idx: Integer;
  Page: TOutputMsgMemoWizardPage;
  LicenseFilePath: string;
  RadioButton: TRadioButton;
begin
  Idx := GetArrayLength(LicenseAcceptedRadioButtons);
  SetArrayLength(LicenseAcceptedRadioButtons, Idx + 1);

  Page :=
    CreateOutputMsgMemoPage(
      LicenseAfterPage, SetupMessage(msgWizardLicense),
      SetupMessage(msgLicenseLabel), SetupMessage(msgLicenseLabel3), '');
  Page.Tag := Idx;

  // Shrink license box to make space for radio buttons
  Page.RichEditViewer.Height := WizardForm.LicenseMemo.Height;
  Page.OnActivate := @LicensePageActivate;

  // Load license
  // Loading ex-post, as Lines.LoadFromFile supports UTF-8,
  // contrary to LoadStringFromFile.
  ExtractTemporaryFile(LicenseFileName);
  LicenseFilePath := ExpandConstant('{tmp}\' + LicenseFileName);
  Page.RichEditViewer.Lines.LoadFromFile(LicenseFilePath);
  DeleteFile(LicenseFilePath);

  // Clone accept/do not accept radio buttons
  RadioButton :=
    CloneLicenseRadioButton(Page, WizardForm.LicenseAcceptedRadio);
  LicenseAcceptedRadioButtons[Idx] := RadioButton;

  RadioButton :=
    CloneLicenseRadioButton(Page, WizardForm.LicenseNotAcceptedRadio);
  // Initially not accepted
  RadioButton.Checked := True;

  LicenseAfterPage := Page.ID;
end;

procedure InitializeWizard();
begin
  LicenseAfterPage := wpLicense;
  AddLicensePage('license2.txt');
  AddLicensePage('license3.txt');
  AddLicensePage('license4.txt');
end;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Inno Setup 中添加 4 个许可证页面 的相关文章

随机推荐

  • PDO 最后插入 ID 总是正确的吗?

    我有以下代码 我想问的是这个 想象一下 当两个人同时加载页面时 是否存在其他人的查询在检索到最后一个 ID 之前插入 从而混淆 ID 的危险 不 这种情况是不可能的 方法 db gt lastInsertId 返回此数据库连接的最后插入的
  • 将一个 XML 包含在另一个 XML 中并使用 python 解析它

    我想将一个 XML 文件包含在另一个 XML 文件中并用 python 解析它 我正在尝试通过 Xinclude 来实现它 有一个 file1 xml 看起来像
  • 捕获 Exception 对象是否安全

    我使用依赖于异常的 Java 库 简化代码如下 try val eventTime eventTimeString as Date catch case e Exception gt logger error s Can t parse e
  • pandas,根据某些列值和 NAN 组合行

    所以我有一个 pandas 数据框 如下所示 id 1 id 2 value1 value2 1 2 100 NAN 1 2 NAN 101 10 20 200 NAN 10 20 NAN 202 10 2 345 345 我想要一个像这样
  • 比较 YUI 和 Ext JS [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 如何收到 SalesForce 中新潜在客户的通知? [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我希望在 Salesforce 中创建新潜在客户时收到通知 Salesforce 中是否有类似 web
  • 自动将 Google 表格中单元格内容大写的脚本?

    我有一个电子表格 可以输入股票代码 我希望它们始终全部大写 无论它们如何输入 这似乎需要一些脚本 因为除非存在该列的第二个副本 否则无法使用函数来执行此操作 这是不可接受的 我有一个有效的解决方案 但有一个关键问题 代码如下 functio
  • ASP.NET (MVC) 提供图像

    我正在创建一个 MVC 3 应用程序 尽管同样适用于其他技术 例如 ASP NET Forms 并且只是想知道从代码提供图像而不是使用直接虚拟路径 像往常一样 是否可行 性能方面 我的想法是改进提供文件的通用方法 应用安全检查 基于路由值的
  • 将特定位置的安全号码更改为 X

    我是新来的 将数字替换为特定位置的某些字符 我有这组号码 123 45 6789 但我只需要显示这样的 XXX XX 6789 但我只需要更改不包括 破折号 的数字 下面是我的示例代码 var mainStr view ssn text v
  • 如何获取计算样式以及该规则的来源? [复制]

    这个问题在这里已经有答案了 我想获取元素计算样式和应用该规则的 css 文件和行 类似于 Chrome 开发工具在使用 计算 选项卡并单击值旁边的箭头时所做的操作 简而言之 我希望能够使用 javascript 找出这两件事 实际应用于该元
  • 为什么网络开发人员仍然使用元关键字和元描述标签?

    谷歌根本不使用元关键字标签因为关键字主要用于垃圾邮件搜索引擎 Google 不使用元描述标签进行排名 有时 如果部分内容不适合 元描述标签会用于搜索结果中的网站片段 但大多数元描述是根据页面内容自动生成的 并且元描述与页面内容的开头相同 谷
  • 为什么这个函数被应用于一个没有作为参数调用的变量?

    我尝试编写的一些代码遇到了问题 我正在尝试获取坐标列表列表 表示 3D 中形状的可能位置 并形成一个列表 其中包含原始列表中的所有元素以及原始列表中旋转的元素 以便 x y z 坐标也被移动以包括 z x y 和 y z x 我认为用一个例
  • 有没有撤消 git flow init 的命令?

    After git flow init 如何去掉git flow模型 如何从中删除所有相关配置 git config file git flow init force reset git flow init f 如何从以下内容中删除 git
  • PHP使用RSA私钥解密数据

    我有一个程序 使用 C rsa 公钥加密密码 输出字节数组 为了让我轻松传输它并维护数据 我将字节直接转换为十六进制字符串 现在这就是我遇到问题的地方 我将发布数据发送到我的脚本 现在不确定将其转换为什么以及如何解密它 我正在尝试使用htt
  • 在 CKEditor 4.x 中,有没有办法在初始化后获取允许的标签列表?

    有没有办法获取 CKEditor 4 x 准确地说是 4 4 7 中所有允许标签的列表after编辑器已使用所有插件进行初始化 并且所有allowedContentRules and disallowedContentRules或已应用任何
  • 模拟 Windows 8 开始菜单平铺布局引擎

    那么有人知道完美模拟 Windows 8 开始菜单平铺布局引擎的示例代码或控件吗 它应该支持混合的方形和矩形瓷砖 并正确地将方形瓷砖重新包装在矩形瓷砖上方或下方 注意 如果所有瓷砖都是正方形 WrapPanel 就可以工作 但是 一旦您混合
  • AirGoogleMaps 目录必须添加到您的 xCode 项目中才能支持 iOS RN48 上的 GoogleMaps

    我在Android项目中安装了react native maps 效果很好 但我总是出现错误 编译良好 但在ios中执行时出现错误 console error react native maps 必须将 AirGoogleMaps 目录添加
  • 如何在docker镜像中运行signalr blazor客户端的StartAsync连接?

    我创建了默认的 blazor 服务器端应用程序 然后添加Microsoft AspNetCore SignalR Client and ChatHub班级 然后编辑startup cs文件 添加services AddSignalR and
  • 在 MongoDB 中执行搜索/投影时如何重命名字段?

    是否可以重命名查找查询中返回的字段名称 我想用类似的东西 rename 但是我不想更改我正在访问的文档 我只想以不同的方式检索它们 其工作原理如下SELECT COORINATES AS COORDS in SQL 我现在应该做什么 db
  • 在 Inno Setup 中添加 4 个许可证页面

    我遵循了马丁的回答here https stackoverflow com questions 34592002 how to create two licensefile pages in inno setup在我的 Inno Setup