我遵循了马丁的回答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;
通过这段代码,我看到以下问题:
- 许可证 4 页面出现在许可证 2 和 3 之前
- 在第 2 页中,单选按钮最初被初始化为“我不接受”。在这种情况下,“下一步”按钮被启用,用户可以移至下一个屏幕。
图像显示即使选择“我不接受”,“下一步”按钮仍处于启用状态。另外,许可证 4 会先于许可证 2 出现
我知道当我试图扩展马丁的答案以涵盖更多许可证时,我在某个地方犯了一个基本错误,但我还无法弄清楚。
如果有人有解决/调试此问题的想法,请告诉我。
谢谢!
A