2
我需要幫助才能在Inno Setup窗體上放置按鈕(打印協議)以通過打印機打印EULA。將「打印協議」按鈕添加到Inno Setup中的許可證頁面
在安裝過程中,當用戶協議頁面顯示時,有3個按鈕(上一個,下一個和取消)。我想添加一個按鈕打印,以便用戶可以打印EULA文檔。有什麼辦法可以做到嗎?
我需要幫助才能在Inno Setup窗體上放置按鈕(打印協議)以通過打印機打印EULA。將「打印協議」按鈕添加到Inno Setup中的許可證頁面
在安裝過程中,當用戶協議頁面顯示時,有3個按鈕(上一個,下一個和取消)。我想添加一個按鈕打印,以便用戶可以打印EULA文檔。有什麼辦法可以做到嗎?
下面是我放在一起的一個簡單腳本,它在許可證屏幕上顯示一個打印按鈕,然後打開帶有可打印許可證文件的記事本。
ShellExec可以更改爲「打印」謂詞(以代碼顯示但已註釋掉),以便它可以自動打印到默認打印機。這並沒有考慮到沒有安裝打印機的系統。代碼是:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{19ECF086-08A1-4A60-891F-E4D57E1266CF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
LicenseFile=c:\license.txt
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\util\innosetup\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\license.txt"; DestDir: "{tmp}"; Flags: dontcopy
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent
[code]
var PrintButton: TButton;
procedure PrintButtonClick(Sender: TObject);
var ResultCode :integer;
begin
log('test');
ExtractTemporaryFile('license.txt');
//if not ShellExec('Print', ExpandConstant('{tmp}\license.txt'),
// '', '', SW_SHOW, ewNoWait, ResultCode) then
if not ShellExec('', ExpandConstant('{tmp}\license.txt'),
'', '', 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;
CurCeChanged的執行正在傷害我的眼睛!請執行'PrintButton.Visible:= CurPage = wpLicense;'來代替! – 2011-12-22 19:03:02
是的,我把它從一個更大的腳本中剝離出來,在不同的頁面上做了一些事情。我現在修好了。 – mirtheil 2011-12-22 19:24:00
謝謝mirtheil ...非常感謝。閱讀腳本後,它看起來很容易。 :) – mchicago 2011-12-23 08:09:53