two digits in edit control
-
Hi! How is it possible to limit my edit control (MFC) to only accept two digits. Now it is possible to type in how many as you want. To get it to accept only numbers were no problems, is there any properties that I can set to get it to only accept two digits as well?
-
Hi! How is it possible to limit my edit control (MFC) to only accept two digits. Now it is possible to type in how many as you want. To get it to accept only numbers were no problems, is there any properties that I can set to get it to only accept two digits as well?
No, you will need to subclass your edit control. It is not really complicated: with class wizard create a new MFC class and make it inherits from CEdit. Then override the OnChar() member function (response to the WM_CHAR event). In this function, if you don't want to add a new char in the edit control, don't call OnChar from the CEdit class. If the character can be displayed, then call CEdit::OnChar(). Hope this help
-
Hi! How is it possible to limit my edit control (MFC) to only accept two digits. Now it is possible to type in how many as you want. To get it to accept only numbers were no problems, is there any properties that I can set to get it to only accept two digits as well?
CEdit::SetLimitText Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"