I want to find the number of words in a rich edit control. There is no direct class member to do this. So I think if I can count the number of word break and line brake then it is easy. But it is also not easy. On the MSDN also it is not well documented. Can you guys give me a clue.
I want to find the number of words in a rich edit control. There is no direct class member to do this. So I think if I can count the number of word break and line brake then it is easy. But it is also not easy. On the MSDN also it is not well documented. Can you guys give me a clue.
Thanks.
If your RichEdit control is on a dialog box call GetDlgItemText and then count the number of spaces in the lpString.
You can also use EM_GETTEXTRANGE message if you know the handle of the control to retrive the text and then count number of white space.
@eranga262154 Once you get the string, counting the number of words should not be a big problem.
"Number of Words = Number of space + 1" is focusing simplest case. However, be careful you may have audience and users like iamthwee (no offence), who may spoil your algorithm.
Re: Word break and line break in Rich Edit Control
Something like this will be easy. There are more compilicated methods if you want to break Japanese or Chinese words. Also you can use a callback function to count the words on the fly, but I think this is the most simple way.
Yes that's what I'm going to do. Find the number of spaces, tabs, carriage returns of the string. I can get the string from the rich edit control. How about the following attempt.
That is one of the big problem I've got. Multiple such instances(like spaces and tab, two spaces, and such..). So please look at my code, how I try to avoid it.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.