为什么自定义页面上的单选按钮没有在Inno设置中选中?



为什么不检查rbStandardInstallTyperbCustomInstallType单选按钮,即使我将其中一个的Checked属性设置为True?另一方面,rbDefaultMSSQLInstancerbNamedMSSQLInstance单选按钮确实会被选中。

我创建这样的单选按钮:

function CreateRadioButton(
AParent: TNewNotebookPage; AChecked: Boolean; AWidth, ALeft, ATop, AFontSize: Integer;
AFontStyle: TFontStyles; const ACaption: String): TNewRadioButton;
begin
Result := TNewRadioButton.Create(WizardForm);
with Result do
begin
Parent := AParent;
Checked := AChecked;
Width := AWidth;
Left := ALeft;
Top := ATop;
Font.Size := AFontSize;
Font.Style := AFontStyle;
Caption := ACaption;
end;
end;

我有两个自定义页面,必须在左侧显示我的图像,在右侧显示一些文本和单选按钮(每页2个单选按钮(。所以,在我的InitializeWizard过程中,我写了这样的:

wpSelectInstallTypePage := CreateCustomPage(wpSelectDir, 'Caption', 'Description');
rbStandardInstallType := CreateRadioButton(WizardForm.InnerPage, True, WizardForm.InnerPage.Width, ScaleX(15), WizardForm.MainPanel.Top + ScaleY(30), 9, [fsBold], 'Standard');
rbCustomInstallType := CreateRadioButton(WizardForm.InnerPage, False, rbStandardInstallType.Width, rbStandardInstallType.Left, rbStandardInstallType.Top + rbStandardInstallType .Height + ScaleY(16), 9, [fsBold], 'Custom');
wpMSSQLInstallTypePage := CreateCustomPage(wpSelectInstallTypePage.ID, 'Caption2', 'Description2');
rbDefaultMSSQLInstance := CreateRadioButton(WizardForm.InnerPage, True, WizardForm.InnerPage.Width, ScaleX(15), WizardForm.MainPanel.Top + ScaleY(30), 9, [fsBold], 'DefaultInstance');
rbNamedMSSQLInstance := CreateRadioButton(WizardForm.InnerPage, False, rbDefaultMSSQLInstance.Width, rbDefaultMSSQLInstance.Left, rbDefaultMSSQLInstance.Top + rbDefaultMSSQLInstance.Height + ScaleY(10), 9, [fsBold], 'NamedInstance');

最后,这里是我的CurPageChanged代码,以便正确显示所有控件:

procedure CurPageChanged(CurPageID: Integer);
begin
case CurPageID of
wpSelectInstallTypePage.ID, wpMSSQLInstallTypePage.ID:
WizardForm.InnerNotebook.Visible := False;  
else
WizardForm.InnerNotebook.Visible := True;
end;
rbDefaultMSSQLInstance.Visible := CurPageID = wpMSSQLInstallTypePage.ID;
rbNamedMSSQLInstance.Visible := CurPageID = wpMSSQLInstallTypePage.ID;
rbStandardInstallType.Visible := CurPageID = wpSelectInstallTypePage.ID;
rbCustomInstallType.Visible := CurPageID = wpSelectInstallTypePage.ID;
end

您将单选按钮添加到错误的父控件(WizardForm.InnerPage(中。不适用于您正在创建的自定义页面。然后,您可以通过在CurPageChanged中显式隐藏/显示单选按钮来解决该缺陷。

由于所有四个单选按钮都具有相同的父按钮(WizardForm.InnerPage(,因此只能选中其中一个。因此,当您检查rbDefaultMSSQLInstance时,rbStandardInstallType是隐式未检查的。


有关正确的代码,请参阅:
Inno设置在自定义页面上放置图像/控件

(确保删除多余的CurPageChanged代码(


您还应该考虑使用CreateInputOptionPage,而不是手动将单选按钮添加到通用自定义页面。

最新更新