Character Counter in MFC
-
If anyone can help me with a character counter, I would be very appreciative. I have a Rich Text Edit box in an MFC app. I would like to limit the number of characters a user enters by having a "Characters Left" count box below my edit box indicating how many additional characters the user has left. This counter chould be dynamic enough so users would actually see the number decrement by one for each character typed, and if they deleted a 5 letter word, it should go up by 5. In addition, when the counter is 0, the edit box should not allow any more input. This should be similar to the java script done on many HTMLs. Anyone ever done this before in C++ MFC? Can anyone provide me with a suggestion on where to begin? Thank you!!!
-
If anyone can help me with a character counter, I would be very appreciative. I have a Rich Text Edit box in an MFC app. I would like to limit the number of characters a user enters by having a "Characters Left" count box below my edit box indicating how many additional characters the user has left. This counter chould be dynamic enough so users would actually see the number decrement by one for each character typed, and if they deleted a 5 letter word, it should go up by 5. In addition, when the counter is 0, the edit box should not allow any more input. This should be similar to the java script done on many HTMLs. Anyone ever done this before in C++ MFC? Can anyone provide me with a suggestion on where to begin? Thank you!!!
Hi! the "normal" edit control has a method, that allows you to set the maximum input len. So I guess, the RichEditControl has some similar method. and then, you can catch the TEXT_CHANGED message (don't know the correct name :) ) , get the text from the control, calculate the Len and update your "counter" control.
-
Hi! the "normal" edit control has a method, that allows you to set the maximum input len. So I guess, the RichEditControl has some similar method. and then, you can catch the TEXT_CHANGED message (don't know the correct name :) ) , get the text from the control, calculate the Len and update your "counter" control.
-
Yea, I know the "concept" behind what I need to do, I just cant find any specifics. TEXT_CHANGED is nice, but again, the real name alludes me. I simply cannot find it and I am getting a little frustrated. :((
-
:) It seems, you must derive a class from CRichEditCtrl and catch the WM_KEYUP message. Don't know why, but my parent window don't get any messages from the RichEdit :(
Yea, it seems that the parent window doesn't get the KEYUP message with me either and that was the problem I was having. I solved this problem by adding a message handler to the IDC_EDIT for EN_CHANGE messages. That worked great. I dont understand how or why it works with a rich edit, but who knows...and at this point who cares. Its done! Thanks for the help.