Inno Setup:如何选中复选框显示(隐藏/取消隐藏)密码

时间:2019-03-30 20:48:34

标签: inno-setup pascalscript

我正在向输入查询页面添加一个复选框,以使用该复选框向我显示被选中时发现的密码。但是我不知道该怎么做。

我已经创建了以下过程。但是,此过程并不会改变添加输入时的真假值。此过程为我添加了完成该工作的新文本框。

能请你帮我吗?

procedure SPCheckBoxChecked(Sender: TObject);
begin
    if Assigned(SPCheckBox) then
  begin
    if SPCheckBox.Checked then
       CredentialsPage.Add('Password:', False)
    if not SPCheckBox.Checked then
       CredentialsPage.Add('Password:', True)
  end;
end;

1 个答案:

答案 0 :(得分:1)

使用TPasswordEdit.Password属性:

[Code]

var
  InputQueryPage: TInputQueryWizardPage;

procedure ShowPasswordCheckClick(Sender: TObject);
begin
  InputQueryPage.Edits[0].Password := not TNewCheckBox(Sender).Checked;
end;

procedure InitializeWizard();
var
  ShowPasswordCheck: TNewCheckBox;
begin
  InputQueryPage :=
    CreateInputQueryPage(wpWelcome, 'Password prompt', 'Please enter your password', '');
  InputQueryPage.Add('Password:', True);

  ShowPasswordCheck := TNewCheckBox.Create(WizardForm);
  ShowPasswordCheck.Parent := InputQueryPage.Surface;
  ShowPasswordCheck.Top :=
    InputQueryPage.Edits[0].Top + InputQueryPage.Edits[0].Height + ScaleY(8);
  ShowPasswordCheck.Height := ScaleY(ShowPasswordCheck.Height);
  ShowPasswordCheck.Caption := '&Show password';
  ShowPasswordCheck.OnClick := @ShowPasswordCheckClick;
end;

enter image description here

enter image description here