Inno Setup: How to show (hide/unhide) password on checkbox checked

时光毁灭记忆、已成空白 提交于 2021-01-01 04:58:43

问题


I am adding a checkbox to my input query page to use it to show me the password uncovered, when is checked. But I don't know how to do that.

I already created the following procedure. But this procedure does not change me the true false value on add input. This procedure adds me new textbox that do the job.

Could you please help me?

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:


Use TPasswordEdit.Password property:

[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;



来源:https://stackoverflow.com/questions/55435520/inno-setup-how-to-show-hide-unhide-password-on-checkbox-checked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!