Solved

CEdit control with ES_PASSWORD style

Posted on 1998-10-09
7
1,374 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

14 Experts available now in Live!

Get 1:1 Help Now