And*_*kle 4 inno-setup pascalscript
这是一个标准 RTF 文档,用于Inno Setup 部分LicenseFile中的属性:[Setup]
是否可以在此页面添加一个打印按钮来触发打印许可协议?
我看到了一个类似的问题和答案(在 Inno Setup 中的许可证页面中添加“打印协议”按钮),我刚刚尝试实现。但这就是我得到的:
该按钮位于错误的位置,因此此代码似乎与 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;
Run Code Online (Sandbox Code Playgroud)
我也不清楚哪个代码是正确的“打印”此协议。
它实际上并不是关于 Inno Setup 6,而是关于WizardStyle=modern.
如果要将控件放置在页面底部,请使用相对于向导大小的坐标,而不是绝对坐标。或者更好的是,使用相对于您想要对齐的控件的坐标。该代码显然想要将Print按钮与Next等其他按钮对齐,所以这样做:
PrintButton.Top := WizardForm.NextButton.Top;
Run Code Online (Sandbox Code Playgroud)
您正在使用WizardStyle=modern,它比经典向导更大。当时InitializeWizard,现代风格尚未应用。因此,即使“下一步”按钮也没有位于其最终位置。为了满足这一点,请使用akBottom锚点(如下NextButton所示):
PrintButton.Anchors := [akLeft, akBottom];
Run Code Online (Sandbox Code Playgroud)
这也是必须的,因为现代向导是用户可调整大小的,因此您需要将按钮粘在底部,即使向导大小稍后发生变化。
将按钮相对于 放置WizardForm.InfoAfterPage.Left是无意义的,因为这总是0。您可能想使用:
PrintButton.Left :=
WizardForm.OuterNotebook.Left + WizardForm.InnerNotebook.Left;
Run Code Online (Sandbox Code Playgroud)
不要依赖默认大小,默认大小不会缩放:
您可以使用要对齐的其他控件的大小:
PrintButton.Width := WizardForm.NextButton.Width;
PrintButton.Height := WizardForm.NextButton.Height;
Run Code Online (Sandbox Code Playgroud)
ScaleX始终使用和缩放偏移和尺寸ScaleY。请参阅在 Inno Setup 自定义页面上放置图像/控件。但如果您应用上述所有内容,您将不会留下任何固定的坐标或尺寸。
现在,无论您使用什么风格的 Inno Setup 向导,或者您的安装程序将在什么 DPI 上运行,您的代码都可以正常工作。
| 归档时间: |
|
| 查看次数: |
363 次 |
| 最近记录: |