Solved

CEdit control with ES_PASSWORD style

Posted on 1998-10-09
7
1,411 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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: 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…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

690 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