Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Modifying User Input in an Edit Control

Posted on 2003-02-24
4
Medium Priority
?
235 Views
Last Modified: 2013-11-20
I have made modified control class based on the Edit Control.  My main objective is to limit the user to only enter hexidecimal digits (0-9A-F).  I have successfully done this by making my own WM_CHAR message handler.  What I want to do now is allow the user to enter a-f but have the message handler interpret it as A-F (i.e. make all the characters capital letters).  I have tried the following and it does not work.


void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
  if ('a'==nChar)
     CEdit::OnChar('A',nRepCnt,nFlags);
}

This is only a subset of the actual code.  Are there any other ways to accomplish this.
0
Comment
Question by:davidzier
  • 2
4 Comments
 

Expert Comment

by:abelblaine111
ID: 8014872
Try this function.

LPTSTR CharUpper(LPTSTR lpsz );

with that you should be able to pass it either a string or char and get back all Uppercase.  Then you don't even need to check to see if something is lower case.  If it passes the test of a-f then just capitalize it with CharUpper and pass it.
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 200 total points
ID: 8014911
Use ES_UPPERCASE CEdit style.
0
 

Author Comment

by:davidzier
ID: 8020576
To abelblaine111:
I could not accept your answer becuase there there is no easy way, from what I can tell, to use the CharUpper.  Note that the value I get from nChar is an integer and not a string.  Additionally, what I am doing in my code is the same thing, except I am brute forcing the result.
0
 

Author Comment

by:davidzier
ID: 8020590
This was just the most simplist and accurate result.  So simple in fact, that I completely overlooked that the CEdit class has this style tag.  I have done this and it works perfectly now.  Thank you :)

DZ
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

580 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