I need a solution to restrict my Edit Box to accept only 0 to 9 and A,B, C, D, E, F key strokes.
Please advice
Printable View
I need a solution to restrict my Edit Box to accept only 0 to 9 and A,B, C, D, E, F key strokes.
Please advice
You have to SUBCLASS the edit control.
Derive a class from CEDIT , call it HEXEDIT and then create a message handle for the WM_CHAR message: use class wizard.
.... anyhow look up "SUBCLASSING CEdit" on google and I'm sure you'll figure it out!!
ADSOFT is right.
but if you don't wont to do this on your own (or if you don't know how :) )
try this article:
http://www.codeguru.com/Cpp/controls...icle.php/c539/
good luck
It can be solved if you understand the keyborad message& character message translation
see attached class.Quote:
Originally posted by Bizybs
I need a solution to restrict my Edit Box to accept only 0 to 9 and A,B, C, D, E, F key strokes.
Please advice
There is another solution to this problem
do the following-
1. Add a function for the EN_UPDATE Message for the Edit Control
2. In the OnUpdate function get the character just typed say ch
3. isxdigit(ch) can be used to verify that it is a digit 0-9, A-F.
That should work.
actually I had asked the same question. read it.
thread
Must keep in mind that cut, copy, paste are supported by edit box. So, you must validate the whole new text added not just last character in OnUpdate handler.
Amit