Vampire
Vampire

Reputation: 93

How to show password while typing in Inno Setup?

I have created a setup with Inno Setup via Wizard method and used a password. But when I ran setup and in Password screen, password is hidden while typing (****). I want password to be shown while typing. Can somebody guide me?

Upvotes: 3

Views: 641

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202360

Set TPasswordEdit.Password property of WizardForm.PasswordEdit to False:

<event('InitializeWizard')>
procedure InitializeWizardRevealPassword();
begin
  WizardForm.PasswordEdit.Password := False;
end;

If you want to allow the user to toggle the display of the password, you have to add a custom checkbox.

var
  ShowPasswordCheck: TNewCheckBox;

procedure ShowPasswordCheckClick(Sender: TObject);
begin
  WizardForm.PasswordEdit.Password := not ShowPasswordCheck.Checked;
end;

<event('InitializeWizard')>
procedure InitializeWizardRevealPassword();
begin
  ShowPasswordCheck := TNewCheckBox.Create(WizardForm);
  ShowPasswordCheck.Parent := WizardForm.PasswordEdit.Parent; 
  ShowPasswordCheck.Caption := '&Show password';
  ShowPasswordCheck.Top :=
    WizardForm.PasswordEdit.Top + WizardForm.PasswordEdit.Height + ScaleY(8);
  ShowPasswordCheck.Height := ScaleY(ShowPasswordCheck.Height);
  ShowPasswordCheck.Checked := not WizardForm.PasswordEdit.Password;
  ShowPasswordCheck.OnClick := @ShowPasswordCheckClick;
end;

enter image description here

Upvotes: 5

Related Questions