Modifying User Input in an Edit Control

Posted on 2003-02-24
Medium Priority
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)

This is only a subset of the actual code.  Are there any other ways to accomplish this.
Question by:davidzier
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
  • 2

Expert Comment

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.
LVL 48

Accepted Solution

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

Author Comment

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.

Author Comment

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 :)


Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

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…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 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