Solved

TMaskEdit with PASSWORDCHAR set to *

Posted on 1998-11-15
7
965 Views
Last Modified: 2010-04-04
I am using a TMaskEdit with passwordchar set to * to hide the 5 digits entered by the user. The mask is set to 99999;0;

The problem is that the 5 * are displayed all the time, even when there is no characters in the maskedit. I would like the maskedit to be blank when no character have been entered.
0
Comment
Question by:moonrise
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 80 total points
ID: 1346933
Use a TEdit instead of a TMaskEdit and write a handler for the OnKeyDown event. In this event discard the key if it is not a digit. If the entered number if 5 digits then discard all further keypresses.

eg:
  if Length(Text) = 5 then
   key := #0
 else
   if not (key in ['0'..'9']) then
     key := #0

Cheers,

Raymond.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1346934
Hello moonrise ;-)

Raymond's code can be simply written as follows

if (Length(Text) = 5 and not (key in ['0'..'9'])) then key := #0

;-)

Cheers,
Viktor
0
 

Author Comment

by:moonrise
ID: 1346935
Thank you both.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:rwilson032697
ID: 1346936
Of course after Viktor compiled it he would change it to:

if (Length(Text) = 5) and not (key in ['0'..'9']) then key := #0

:-)

Cheers,

Raymond.

Thought for the day: Complexity and complication are not the same.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1346937
Hello jelousy :)

I didn't compile anything... I just know Delphi well ;-)

I haven't opened Delphi for more than a month if you want to know...

btw- Did you compile it to see if it really works, eh?

Cheers,
Viktor
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1346938
Of course I didn't compile it Viktor! That would be taking all the fun out of it!

Raymond.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1346939
Good for you... I just wanted you to know that I didn't compile it also :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question