Tech Support > Microsoft Windows > Development Resources > RichEdit and carriage returns
RichEdit and carriage returns
Posted by KevinL on July 16th, 2003


I'm implementing a text editor with RichEdit coupled with the text
object model. I use the GetText method under ITextRange to retrieve
the text and process it.

If I type in a single line in the control, GetText returns the text as
expected.

What puzzles me is the behavior when I type in a line break. Let's
say I hit 'a' followed by 'return' followed by 'a'. GetText returns
four characters:
'a', CR, 'a', CR

Where did that last CR come from? Under what circumstances can I
always expect RichEdit to append the extra CR? Is this consistent
across all versions? I'd like to trim off that CR before processing
the text; to do that I'd have to be sure that the user didn't input it
himself.

On a tangent, I think I've read somewhere that RichEdit used to use
LF/CR for linebreaks...at what version did that change to CR alone?

Posted by KevinL on July 16th, 2003


On Wed, 16 Jul 2003 00:45:36 GMT, KevinL <inkdust@hotmail.com> wrote:

Turns out that using the GETTEXTLENGTHEX message under richedit will
return the precise character count. A bit testing seems to have it
working well.

So never mind.


Similar Posts