gpt4 book ai didi

radio-button - 带有单选按钮的 TInputDirWizardPage

转载 作者:行者123 更新时间:2023-12-04 16:04:18 27 4
gpt4 key购买 nike

我需要一个带有两个单选按钮的设置页面。单击第二个按钮应启用定义路径的输入(就像在 TInputDirWizardPage 中完成的那样)。

是否可以根据我的需要自定义 TInputDirWizardPage

还是需要自己构建一个CustomPage,然后自己定义控件?如果第二个问题的回答是肯定的,我如何使用“目录输入”(来自 TInputDirWizardPage),或者是否也需要自己构建它?

最佳答案

正如您猜对的那样,您有多种选择:

  1. TWizardPage 开始,从头开始构建一切
  2. TInputDirWizardPage 开始并添加单选按钮
  3. TInputOptionWizardPage 开始并添加编辑框

第二个选项可能涉及最少的定制。虽然它需要来自 Is it possible to allow a user to skip a TInputDirWizardPage in Inno Setup? 的 hack

{ WORKAROUND }
{ Checkboxes and Radio buttons created on runtime do }
{ not scale their height automatically. }
{ See https://stackoverflow.com/q/30469660/850848 }
procedure ScaleFixedHeightControl(Control: TButtonControl);
begin
Control.Height := ScaleY(Control.Height);
end;

var
Page: TInputDirWizardPage;
DefaultLocationButton: TRadioButton;
CustomLocationButton: TRadioButton;
OldNextButtonOnClick: TNotifyEvent;

procedure LocationButtonClick(Sender: TObject);
begin
Page.Edits[0].Enabled := CustomLocationButton.Checked;
Page.Buttons[0].Enabled := CustomLocationButton.Checked;
end;

procedure NextButtonOnClick(Sender: TObject);
var
PrevDir: string;
begin
{ Do not validate, when "default location" is selected }
if (WizardForm.CurPageID = Page.ID) and DefaultLocationButton.Checked then
begin
PrevDir := Page.Values[0];
Page.Values[0] := GetWinDir; { Force value to pass validation }
OldNextButtonOnClick(Sender);
Page.Values[0] := PrevDir;
end
else
begin
OldNextButtonOnClick(Sender);
end;
end;

procedure InitializeWizard();
begin
Page := CreateInputDirPage(
wpWelcome,
'Select Personal Data Location', 'Where should personal data files be stored?',
'', False, 'New Folder');
Page.Add('');

DefaultLocationButton := TRadioButton.Create(WizardForm);
DefaultLocationButton.Parent := Page.Surface;
DefaultLocationButton.Top := Page.Edits[0].Top;
DefaultLocationButton.Caption := 'Use default location';
DefaultLocationButton.Checked := True;
DefaultLocationButton.OnClick := @LocationButtonClick;
ScaleFixedHeightControl(DefaultLocationButton);

CustomLocationButton := TRadioButton.Create(WizardForm);
CustomLocationButton.Parent := Page.Surface;
CustomLocationButton.Top :=
DefaultLocationButton.Top + DefaultLocationButton.Height + ScaleY(8);
CustomLocationButton.Caption := 'Use custom location';
CustomLocationButton.OnClick := @LocationButtonClick;
ScaleFixedHeightControl(DefaultLocationButton);

Page.Buttons[0].Top :=
Page.Buttons[0].Top +
((CustomLocationButton.Top + CustomLocationButton.Height + ScaleY(8)) -
Page.Edits[0].Top);
Page.Edits[0].Top :=
CustomLocationButton.Top + CustomLocationButton.Height + ScaleY(8);
Page.Edits[0].Left := Page.Edits[0].Left + ScaleX(16);
Page.Edits[0].Width := Page.Edits[0].Width - ScaleX(16);
Page.Edits[0].TabOrder := CustomLocationButton.TabOrder + 1;
Page.Buttons[0].TabOrder := Page.Edits[0].TabOrder + 1;

LocationButtonClick(nil); { Update edit for initial state of buttons }

OldNextButtonOnClick := WizardForm.NextButton.OnClick;
WizardForm.NextButton.OnClick := @NextButtonOnClick;
end;

enter image description here

enter image description here


关于该主题的更一般性问题:Inno Setup Placing image/control on custom page .

关于radio-button - 带有单选按钮的 TInputDirWizardPage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49358778/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com