Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Masking/Hiding text in input

Status
Not open for further replies.

CHeighlund

Programmer
Jun 11, 2007
163
US
I'm working with a password screen for a project. I thought I had the screen ready to go, but then I realized a rather glaring flaw in my setup: The password is visible (readable, rather) in the associated text field.

I saw in one post something about a passwordchar property, but the text boxes I'm using don't appear to have that property available on them. Lacking this, how do I go about with the mask/hide attempt? I've been trying to work with a second text box and the OnKeyPress event in the first one, which seems to be doing most of what I want (OnKeyPress: Box2.Text := Box2.Text + Key; Key = '#'), but attempting to back up and delete characters in the first box doesn't seem to be working. The second box still contains everything that it had before the delete began.

Any suggestions about how I could correct this would be appreciated. Alternately, if anyone has a better method of creating the password box, I would appreciate hearing about that as well.
 
what delphi version are you using?
there is an easy solution for your problem...

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
if your TEdit does not have the PasswordChar property then you can do this:

Code:
SendMessage(Edit1.Handle, EM_SETPASSWORDCHAR, Ord('*'), 0);

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
thread102-1449472 might present some thoughts on what you're trying to do.

----------
Those who work hard are rewarded with more work and remembered come time to downsize. Those who hardly work are given a paycheck and ignored completely.
 
@whosrdaddy:
Delphi 7. And where would that code segment be placed - form create, OnKeyPress event, ???
 
@Glenn9999:

I'd already seen that thread when I went looking for a possible solution. It's the one that got me as far as I have gone...so thanks, I guess, for the work you did then. The problem I'm having is at the last step, though, and my own edit boxes don't appear to have the "Perform" property either; an attempt to directly copy-paste that code into my own codeset (with appropriate changes for the equivalent component name) threw an error at compile time because it didn't recognize "Perform".
 
form create would be a good place. It sets the password char to *. this means you can still use the .text property to read the real text. undo the password char by replacing Ord('*') with 0.

/daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
@whosrdaddy:

Getting an error message at compile time.

"Incompatible types: 'HWND' and 'QClxLineEditH'". Triggering on the Edit box's .Handle parameter.
 
are you using the normal TEdit? (not the CLX version)?

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I thought I was. All I was doing was adding an Edit component from the top of the bar to a new form. However, given that the project wasn't originally built by me, I suppose it's somehow possible what I'm getting handed to me are CLX equivalents. Any suggestions on either changing those to normal, or on how to work with those?
 
Apparently I was working with the CLX components. A new form, built separately and known to be using the normal components (because it has the Perform procedure and correct Handle attribute) works nicely in isolation. The problem now will be getting it to mesh with the previous program.

Thank you to both of you for your gracious assistance in this matter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top