8 10 Votes

Delphi: Password Edit

Tip by Delphian | 28/12/2012 at 15:18

If you want to implement a login area in your Delphi program, it is handy to design the box for entering the password like a password input field in the browser: That is, the input characters are not displayed in clear text. Instead asterisks or dots are shown.

For the realization of such a project, we need no special component in Delphi, we can just take our normal TEdit to mask the input, that provides already the PasswordChar property innately:

// normal display in plain text
Edit1.PasswordChar := #0;
 
// input is masked with *
Edit1.PasswordChar := '*';
 
// input is masked with a point
Edit1.PasswordChar := #180;

You can easily set this property by using the Object Inspector or the code above. The character #0 (default value) ensures that the input is shown in plain text. All other characters except #0 lead that this specified character is displayed instead of the characters entered. In the example, we show this for the asterisk '*' and the center point (that has the value #180). Of course, you can also use any other character you want to use as a mask.

Internally and in the code, the value of the edit can simply be used and processed as usual with Edit1.Text.

ReplyPositiveNegative

About the Author

Avatar AuthorThe author has not added a short description to his profile yet.
Show Profile | Message

 

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.