How to create a CEdit derived class
-
Hi to all, I would like to create a CEDit derived class with the following caratteristic: Every time the user digits a char in the edit box, the class should control the value of that char and compare it with a defined list of allowed chars If the char doesn't match the list, char should not be accepted and a MessageBeep should be prompt Anyone can help me? Thanks in advance
-
Hi to all, I would like to create a CEDit derived class with the following caratteristic: Every time the user digits a char in the edit box, the class should control the value of that char and compare it with a defined list of allowed chars If the char doesn't match the list, char should not be accepted and a MessageBeep should be prompt Anyone can help me? Thanks in advance
Insert New Class give new name for class and derived it from CEdit by selecting it from combobox. And write your validation code in OnChar() ( u have to add this fucntion thru class wizard WM_CHAR ) Jetli Constant Thing In World Is Change.
-
Hi to all, I would like to create a CEDit derived class with the following caratteristic: Every time the user digits a char in the edit box, the class should control the value of that char and compare it with a defined list of allowed chars If the char doesn't match the list, char should not be accepted and a MessageBeep should be prompt Anyone can help me? Thanks in advance
Hi, It is quite simpe to do: with Class Wizard, create your own class (call it CMyEdit for example) and make it inherits from CEdit. Then override the OnChar method (not 100% sure about the function name but I think this is good). In this function, compare the char entered with those in your list. If it is not allowed, don't call OnChar from the parent (CEdit::OnChar() ). Otherwise call it and it will add the char in the edit box. You will probably need to add a function to send your list to the class also. Call this function in the initalisation of your dialog box that contains your edit control. Now, to add your specific control, use the resource editor and paste a standard edit, and with class wizard, you will have the possibility to choose your class to be associated with the control. That's it Hope this helps
-
Hi to all, I would like to create a CEDit derived class with the following caratteristic: Every time the user digits a char in the edit box, the class should control the value of that char and compare it with a defined list of allowed chars If the char doesn't match the list, char should not be accepted and a MessageBeep should be prompt Anyone can help me? Thanks in advance
-
Just a heads up, if you do your verification in OnChar your users will be able to enter invalid characters via copy 'n paste. You are much better off handling the verification in the OnUpdate (EN_UPDATE) handler. Check out the edit controls section here on CP for validating edit controls for sample code.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
Honoured as one of The Most Helpful Members of 2004