即使我将其中一个的rbStandardInstallType
属性设置为rbCustomInstallType
,为什么也没有选中Checked
和True
单选按钮?另一方面,确实选中了rbDefaultMSSQLInstance
和rbNamedMSSQLInstance
单选按钮。
我创建如下单选按钮:
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个自定义页面,我必须在左侧显示我的图像,并在右侧显示一些文本和单选按钮(每页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
答案 0 :(得分:0)
您正在将单选按钮添加到错误的父控件(WizardForm.InnerPage
)。不访问正在创建的自定义页面。然后,您可以通过显式隐藏/显示CurPageChanged
中的单选按钮来解决该缺陷。
由于所有四个单选按钮都具有相同的父项(WizardForm.InnerPage
),因此只能选中其中一个。因此,当您检查rbDefaultMSSQLInstance
时,rbStandardInstallType
被隐式取消选中。
有关正确的代码,请参见:
Inno Setup Placing image/control on custom page
(确保您删除了多余的CurPageChanged
代码)
您还应该考虑使用CreateInputOptionPage
,而不是手动将单选按钮添加到通用自定义页面。