Hello,

i wanted to create a CEdit control which takes in as input only 0 through 9 and a/A through f/F.

i believe i should simply trap the CEdit's WM_CHAR message, right and do the following...


void CHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
UINT mynChar;
if(isdigit(nChar) || nChar == 'a' || nChar == 'A' || nChar == 'b' || nChar == 'B' \
|| nChar == 'c' || nChar == 'C' || nChar == 'd' || nChar == 'D' \
|| nChar == 'e' || nChar == 'E' || nChar == 'f' || nChar == 'F')
{
mynChar = nChar;
CEdit::OnChar(mynChar, nRepCnt, nFlags);
}
else
mynChar = 0;
CEdit::OnChar(mynChar, nRepCnt, nFlags);
}




Unfortunately, this does not work.

So, i tried the following...


void CHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
UINT mynChar;
if((nChar >= 48 && nChar <=57) || (nchar >= 65 && nChar <=70) || (nchar >= 97 && nChar <=102))
{
mynChar = nChar;
CEdit::OnChar(mynChar, nRepCnt, nFlags);
}
else
mynChar = 0;
CEdit::OnChar(mynChar, nRepCnt, nFlags);
}





This does not work too!

Any suggestions?

Regards
Rajeev