Solved

CEdit control with ES_PASSWORD style

Posted on 1998-10-09
7
1,409 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
[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
  • 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
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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 84
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 547
maxBlock challenge 30 150
matchUp  challenge 6 82
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

732 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