1
votes

I spent a few hours searching Google to see if anyone had shared their articles, but came up empty-handed.

If it's possible, I want to know how to enable/disable the PasswordChar in Delphi XE8's TMemo to hide user input like in TEdit. ? Maybe via a checkbox!

So when the checkbox is checked then all text turned to asterisks, and if the checkbox is unchecked, all text back to normal..

2
So what is your question? Please don't tell me it is "Is there anybody..."Uwe Raabe
We don't even know whether you mean FMX or VCL. And why a memo? Passwords are entered into single line edit controls. Please edit the question to make it clear what you ask.David Heffernan
I have the INI file [ TiniFile ] that contains some settings. When I loads it to memo then i want all text of the INI file contents turned to asterisks, automatically [a checkbox is checked by default]. And if the checkbox is unchecked, all text back to normal.. Please helpMatthew

2 Answers

2
votes

The VCL memo control is a loose wrapper around the Win32 multiline edit. The password character functionality of the edit control is only available for single line edits.

The behaviour is controlled by the ES_PASSWORD style for which the documentation says:

Displays an asterisk (*) for each character typed into the edit control. This style is valid only for single-line edit controls.

The FMX memo control offers no password character functionality for the multiline memo control.

Presumably these frameworks don't offer what you want because passwords are entered in single line edit controls. Developers tend not to provide functionality that has no clear case for being used.

Your options:

  • Use a single line TEdit.
  • Write your own multiline memo that supports your desired functionality.
  • Find a third party multiline memo that supports your desired functionality.

Now, since your question is so general I have assumed that you want full support for single line password character. That is, the user enters text and it appears masked.

But maybe you actually don't need editability. In that case it is simple enough. Do the following:

  1. Load or add the true text into a separate TStringList.
  2. When you want to display the true text assign the string list to the memo.
  3. When you want to hide the content, process the true text into whatever you want to display, and display that.
  4. Make the memo control read only.
-2
votes
if cBoxPassword.checked=false then
edtpassword.PasswordChar:='*';
if cBoxPassword.checked=true then
edtPassword.PasswordChar:=#0;