gpt4 book ai didi

inno-setup - 将打印按钮添加到 Inno Setup 中的许可证页面(为 Inno Setup 6 重新访问)

转载 作者:行者123 更新时间:2023-12-04 14:03:06 27 4
gpt4 key购买 nike

这是用于 Inno Setup 的 [Setup] 部分中的 LicenseFile 属性的标准 RTF 文档:

enter image description here

是否可以向此页面添加打印按钮以触发打印许可协议(protocol)?


我看到了一个类似的问题和答案(Adding a "print agreement" button to the licence page in Inno Setup),我刚刚尝试实现。但这就是我得到的:

enter image description here

按钮在错误的位置,所以这段代码似乎不完全兼容 Inno Setup 6?

所以,在我的脚本中我有:

[Setup]
LicenseFile=..\..\..\EULA\EULA.rtf

[Code]
var PrintButton: TButton;

procedure PrintButtonClick(Sender: TObject);
var ResultCode :integer;
begin
log('test');
ExtractTemporaryFile('EULA.rtf');
//if not ShellExec('Print', ExpandConstant('{tmp}\EULA.rtf'),
// '', '', SW_SHOW, ewNoWait, ResultCode) then
if not ShellExec('', ExpandConstant('{tmp}\EULA.rtf'),
'', '', SW_SHOW, ewNoWait, ResultCode) then
log('test');
end;

procedure InitializeWizard();
begin
PrintButton := TButton.Create(WizardForm);
PrintButton.Caption := '&Print...';
PrintButton.Left := WizardForm.InfoAfterPage.Left + 96;
PrintButton.Top := WizardForm.InfoAfterPage.Height + 88;
PrintButton.OnClick := @PrintButtonClick;
PrintButton.Parent := WizardForm.NextButton.Parent;
end;

procedure CurPageChanged(CurPage: Integer);
begin
PrintButton.Visible := CurPage = wpLicense;
end;

我也不清楚“打印”此协议(protocol)的正确代码。

最佳答案

这不是关于 Inno Setup 6,而是关于 WizardStyle=modern .

  1. 如果您想将控件放在页面底部,请使用相对于向导大小的坐标,而不是绝对坐标。或者更好的是,使用相对于要对齐的控件的坐标。该代码显然想要将 Print 按钮与其他按钮(如 Next)对齐,所以这样做:

    PrintButton.Top := WizardForm.NextButton.Top;
  2. 您正在使用 WizardStyle=modern,它比经典向导更大。在调用 InitializeWizard 时,尚未应用现代风格。因此,即使是 Next 按钮也不在其最终位置。为此,请使用 akBottom anchor (如 NextButton 所做的那样):

    PrintButton.Anchors := [akLeft, akBottom];

    这也是必须的,因为现代向导是用户可调整大小的,因此您需要将按钮固定在底部,即使稍后向导大小发生变化也是如此。

    另见 Inno Setup - aligning custom button with the Cancel button

  3. 相对于 WizardForm.InfoAfterPage.Left 放置按钮是无稽之谈,因为它总是 0。你可能想使用:

    PrintButton.Left :=
    WizardForm.OuterNotebook.Left + WizardForm.InnerNotebook.Left;
  4. 不要依赖无法缩放的默认尺寸:

    enter image description here

    您可以使用要对齐的其他控件的大小:

    PrintButton.Width := WizardForm.NextButton.Width;
    PrintButton.Height := WizardForm.NextButton.Height;
  5. 始终使用 ScaleX 缩放偏移量和大小和 ScaleY .参见 Inno Setup Placing image/control on custom page .尽管如果您应用以上所有内容,您将没有任何固定的坐标或尺寸。

现在,无论您使用何种类型的 Inno Setup 向导,或者您的安装程序将在何种 DPI 上运行,您的代码都可以正常工作。

enter image description here

enter image description here

关于inno-setup - 将打印按钮添加到 Inno Setup 中的许可证页面(为 Inno Setup 6 重新访问),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69403271/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com