Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting PasswordChar in a TEdit in runtime

1 view
Skip to first unread message

Anders Gustavsson

unread,
Dec 6, 2001, 12:45:54 PM12/6/01
to
I made the following code for my program, to call in the OnExit event of an
TEdit:

procedure CheckSignEd(ed: TEdit);
begin
with ed do
if (PasswordChar = '*') and (text <> '') then
begin
try
Text := GetConverted(Text);
PasswordChar := #0; // <--- Here is the problem
except
Text := EmptyStr;
SetFocus;
raise;
end;
end;
end;


The idea is that if you exit 'ed' if it is in password mode, I lookup a
corresponding value (if found) with the GetConverted method (one of my
own!). If GetConverted doesn't find a corresponding value it raises an
exception, otherwise it returns a new value to the editor and I can set
PasswordChar to #0 to show the new value.

The problem is in the PasswordChar := #0 line: PasswordChar doesn't change!

Well, tracking the Borland source code shows it actually does up to a call
to CallWindowProc from a SetTextBuf call in the SetPasswordChar method of
TCustomEdit. So Bill and the boys don't want me to change PasswordChar?

Does anyone have a solution?

/Anders


Micke

unread,
Dec 6, 2001, 12:43:25 PM12/6/01
to
Nej, jag har ingen aning.


Anders Gustavsson

unread,
Dec 6, 2001, 2:56:58 PM12/6/01
to
Sorry about it - you shouldn't write questions to those groups the last
thing you do before going home! In the car on my way home I found out what
was wrong. Don't blame Bill, I am to blame myself.

The method here had a counterpart: in the OnChange of the TEdit I had the
following line:

Edit1.PasswordChar := '*';

with the intention of making any change in the editbox trigger it into
password mode. But of course I have to protect it when i set the converted
text in CheckSignEd!

Thanks to all who gave the problem a thought!

Anders

Peter Below (TeamB)

unread,
Dec 6, 2001, 2:06:58 PM12/6/01
to
In article <3c0fae6b_2@dnews>, Anders Gustavsson wrote:
> I made the following code for my program, to call in the OnExit event of an
> TEdit:
>
> procedure CheckSignEd(ed: TEdit);
> begin
> with ed do
> if (PasswordChar = '*') and (text <> '') then
> begin
> try
> Text := GetConverted(Text);
> PasswordChar := #0; // <--- Here is the problem

Try to replace that with

Perform( EM_SETPASSWORDCHAR, 0, 0 );

If it still does not work you have found a new security feature in Windows
(which platform are you using, by the way?).


Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

David McCallum

unread,
Dec 7, 2001, 3:59:21 AM12/7/01
to
ingen aning.??


--
David McCallum
dm...@actual-systems.com
davidm...@btinternet.com
www.carparts-uk.com
www.carparts-us.com
www.carparts-nl.com

"Micke" <lord...@hotmail.com> wrote in message news:3c0faef4_2@dnews...

0 new messages