delphieditbox

How do I display a label in an edit box, but switch to password-entry mode when it receives focus?


I use Delphi 10 and Windows 10.

The following code makes caret and selection disappear in Edit1.

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  Edit1.PasswordChar := '*';
end;

After the focus moves to the other control and in onClick it works well.

I can't use onClick because the focus moves by tab key and the Edit1 should start with default #0 because it holds text which is 'password' before the focus enters.

How can I solve this?


Solution

  • The edit control works as designed and as expected.