Link to home
Start Free TrialLog in
Avatar of davidzier
davidzier

asked on

Modifying User Input in an Edit Control

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.
Avatar of abelblaine111
abelblaine111

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.
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davidzier

ASKER

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