
我知道當我試圖擴展馬丁的答案以涵蓋其他許可證時,我在某個地方犯了一個基本錯誤,但我還沒有弄清楚。
讓我知道是否有人有解決/除錯此問題的想法。
謝謝!一個
uj5u.com熱心網友回復:
我不會嘗試解決您的問題,因為您將所有代碼重復三次的方式非常低效且難以維護。而是考慮創建其他許可證頁面。像這樣的東西:
[Setup]
LicenseFile=license1.txt
[Files]
Source: "license2.txt"; Flags: dontcopy
Source: "license3.txt"; Flags: dontcopy
Source: "license4.txt"; Flags: dontcopy
[Code]
var
LicenseAcceptedRadioButtons: array of TRadioButton;
procedure CheckLicenseAccepted(Sender: TObject);
begin
// Update Next button when user (un)accepts the license
WizardForm.NextButton.Enabled :=
LicenseAcceptedRadioButtons[TComponent(Sender).Tag].Checked;
end;
procedure LicensePageActivate(Sender: TWizardPage);
begin
// Update Next button when user gets to second license page
CheckLicenseAccepted(LicenseAcceptedRadioButtons[Sender.Tag]);
end;
function CloneLicenseRadioButton(
Page: TWizardPage; Source: TRadioButton): TRadioButton;
begin
Result := TRadioButton.Create(WizardForm);
Result.Parent := Page.Surface;
Result.Caption := Source.Caption;
Result.Left := Source.Left;
Result.Top := Source.Top;
Result.Width := Source.Width;
Result.Height := Source.Height;
// Needed for WizardStyle=modern / WizardResizable=yes
Result.Anchors := Source.Anchors;
Result.OnClick := @CheckLicenseAccepted;
Result.Tag := Page.Tag;
end;
var
LicenseAfterPage: Integer;
procedure AddLicensePage(LicenseFileName: string);
var
Idx: Integer;
Page: TOutputMsgMemoWizardPage;
LicenseFilePath: string;
RadioButton: TRadioButton;
begin
Idx := GetArrayLength(LicenseAcceptedRadioButtons);
SetArrayLength(LicenseAcceptedRadioButtons, Idx 1);
Page :=
CreateOutputMsgMemoPage(
LicenseAfterPage, SetupMessage(msgWizardLicense),
SetupMessage(msgLicenseLabel), SetupMessage(msgLicenseLabel3), '');
Page.Tag := Idx;
// Shrink license box to make space for radio buttons
Page.RichEditViewer.Height := WizardForm.LicenseMemo.Height;
Page.OnActivate := @LicensePageActivate;
// Load license
// Loading ex-post, as Lines.LoadFromFile supports UTF-8,
// contrary to LoadStringFromFile.
ExtractTemporaryFile(LicenseFileName);
LicenseFilePath := ExpandConstant('{tmp}\' LicenseFileName);
Page.RichEditViewer.Lines.LoadFromFile(LicenseFilePath);
DeleteFile(LicenseFilePath);
// Clone accept/do not accept radio buttons
RadioButton := CloneLicenseRadioButton(Page, WizardForm.LicenseAcceptedRadio);
LicenseAcceptedRadioButtons[Idx] := RadioButton;
RadioButton := CloneLicenseRadioButton(Page, WizardForm.LicenseNotAcceptedRadio);
// Initially not accepted
RadioButton.Checked := True;
LicenseAfterPage := Page.ID;
end;
procedure InitializeWizard();
begin
LicenseAfterPage := wpLicense;
AddLicensePage('license2.txt');
AddLicensePage('license3.txt');
AddLicensePage('license4.txt');
end;




轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/525663.html
下一篇:如何將查詢結果插入到記錄中
