Subclassing CEdit, OnChar
-
I'm doing some subclassing to allow only digits and one only of three allowable alpha characters at the end of the edit string. I'm overriding OnChar and find a need to modify the existing string before passing the allowable characters on. However, when I pass any character other than the character trapped by MyCEdit::OnChar to CEdit::OnChar it still results in passing the trapped character. I assume this is the way the system behaves but I don't understand why. Could someone enlighten me? The way I'm getting the job accomplished feels rather kudgy to me and I'd rather avoid it if I can. Thanks, Lilith
-
I'm doing some subclassing to allow only digits and one only of three allowable alpha characters at the end of the edit string. I'm overriding OnChar and find a need to modify the existing string before passing the allowable characters on. However, when I pass any character other than the character trapped by MyCEdit::OnChar to CEdit::OnChar it still results in passing the trapped character. I assume this is the way the system behaves but I don't understand why. Could someone enlighten me? The way I'm getting the job accomplished feels rather kudgy to me and I'd rather avoid it if I can. Thanks, Lilith
try to override WM_KEYDOWN (OnKeyDown?) also. if you control both OnChar and OnKeyDown, it should work.
A nice tool for optimizing your Microsoft html-help contents. Includeh10
-
try to override WM_KEYDOWN (OnKeyDown?) also. if you control both OnChar and OnKeyDown, it should work.
A nice tool for optimizing your Microsoft html-help contents. Includeh10
if you control both OnChar and onkeydown, it should work.
This is the note given in MSDN explaining the correct scenario explaning that you cant fool the system . Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function. in your case map the EN_UPDATE ,check wether the characters are integers and if the count goes above 10 , you do the required . Regards FarPointer. -
if you control both OnChar and onkeydown, it should work.
This is the note given in MSDN explaining the correct scenario explaning that you cant fool the system . Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function. in your case map the EN_UPDATE ,check wether the characters are integers and if the count goes above 10 , you do the required . Regards FarPointer.Actually that's what I originally did except that I used EN_CHANGE, which may have been a mistake. Although a similar approach had worked before, this time I somehow got an odd character at the beginning of the string when I re-read it from the edit control. Using a combination of OnChar to filter the input and EN_CHANGE to process the string at least would have the benefit of reducing my logic's complexity. Lilith