?
Solved

CEdit control with ES_PASSWORD style

Posted on 1998-10-09
7
Medium Priority
?
1,441 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

839 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