在Inno Setup(Inno Setup 6)中将打印按钮添加到许可证页面(重新访问Inno Setup 6) [英] Adding a Print button to the License page in Inno Setup (revisited for Inno Setup 6)
问题描述
这是一个标准RTF文档,用于Inno Setup的[Setup]
部分中的LicenseFile
属性:
是否可以向此页面添加将触发打印许可协议的打印按钮?
我看到了一个类似的问题和答案(Adding a "print agreement" button to the licence page in Inno Setup),这是我刚刚尝试实现的。但我得到的是:
按钮位置错误,因此此代码似乎与安装程序6不完全兼容?
因此,在我的脚本中有:
[Setup]
LicenseFile=......EULAEULA.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;
我也不清楚打印此协议的正确代码是什么。
推荐答案
实际上不是关于Inno Setup 6,而是关于WizardStyle=modern
。
如果要将控件放在页面底部,请使用相对于向导大小的坐标,而不是绝对坐标。或者更好的做法是,使用相对于要对齐的控件的坐标。该代码显然希望将Print按钮与其他按钮(如Next)对齐,因此:
PrintButton.Top := WizardForm.NextButton.Top;
您正在使用的
WizardStyle=modern
比经典向导大。在调用InitializeWizard
时,尚未应用现代风格。因此,甚至下一步按钮也不在其最终位置。为此,请使用akBottom
锚(与NextButton
一样):PrintButton.Anchors := [akLeft, akBottom];
这也是必须的,因为现代的向导是用户可调整大小的,所以您需要将按钮放在底部,即使向导的大小后来发生更改。
另见Inno Setup - aligning custom button with the Cancel button
相对于
WizardForm.InfoAfterPage.Left
放置按钮是无稽之谈,因为总是0
。您可能希望使用:PrintButton.Left := WizardForm.OuterNotebook.Left + WizardForm.InnerNotebook.Left;
不要依赖默认大小,因为默认大小不会缩放:
您可以使用要与之对齐的其他控件的大小:
PrintButton.Width := WizardForm.NextButton.Width; PrintButton.Height := WizardForm.NextButton.Height;
始终使用
ScaleX
和ScaleY
缩放偏移量和大小。请参见Inno Setup Placing image/control on custom page。但是,如果您应用以上所有内容,则不会剩下任何固定的坐标或大小。
现在,无论您使用何种风格的Inno安装向导,也无论您的安装程序将在什么DPI上运行,您的代码都将正常工作。
这篇关于在Inno Setup(Inno Setup 6)中将打印按钮添加到许可证页面(重新访问Inno Setup 6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!