Solved

CEdit control with ES_PASSWORD style

Posted on 1998-10-09
7
1,381 Views
Last Modified: 2013-11-20
There is no problem to set CEdit password attribute using dialog editor. In this case the control replaces all entered characters with '*' (default) or other (defined) symbol.
For some reasons I have problem doing the same thing programmatically.
I use m_edit.ModifyStyle( 0, ES_PASSWORD ) function. If I check in debugger the style after call to it I can see that it becomes absolutely the same as if it would be set by dialog editor.
However programmatic way does not work.
Any idea how to make it work...
0
Comment
Question by:ankor
  • 4
  • 2
7 Comments
 
LVL 3

Expert Comment

by:plaroche
ID: 1323141
There are many cases where a style applied with ModifyStyle does not do anything.  In those cases the style needs to be applied when creating the window (CEdit).

Since your CEdit is in a dialog you will need to create it dynamically, not with the dialog editor.
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1323142
CEdit doesn't respond to WM_STYLECHANGED, i think. And as it doesn't do that, any
changes to its style are simply ignored after creation time. So you should specify
ES_PASSWORD when creating the edit field ( it usually does not make sense to switch
between password and non-password style when it is already visible):

m_cEdit.Create(WS_VISIBLE|WS_CHILD|ES_PASSWORD, ....)
0
 

Author Comment

by:ankor
ID: 1323143
In this case it is definitely makes sense to change style after creation. Why?
Well. I have general keyboard object for touch screen which works just fine.
Now I just got an issue to make it work with secrecy sometimes.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Accepted Solution

by:
plaroche earned 100 total points
ID: 1323144
As snoegler said CEdit does not support dynamic style changing.

The best solution would be for you to have two CEdit, one with the style the other without and switch between them at run-time.

You have to expect that dynamic style changes won't work in many places and sometimes the workaround are not very "cute" but they do the work quite well.

Even subclassing/deriving a CEdit to do what you want will involve much more work if it's possible at all.
0
 

Author Comment

by:ankor
ID: 1323145
How about ES_READONLY? Why you can easy change this flag?
0
 

Author Comment

by:ankor
ID: 1323146
Never mind. I know why. It is changed by EM_SETREADONLY message.
0
 

Author Comment

by:ankor
ID: 1323147
Dear plaroche and snoegler
        // after
        m_edit.ModifyStyle( 0, ES_PASSWORD );
        // should be
        m_edit.SetPasswordChar( '*' );
        // that is it…
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

937 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now