Sign in to follow this  
Evil Steve

Deleting the first X lines in a RichEdit

Recommended Posts

I'm probably missing a blatently obvious message I can send here, but I can't find one to fit what I need. Is there a way to tell a RichEdit to delete the first X lines of a RichEdit? Or a EM_CHARFROMLINE message I can use to get a char index and erase that many chars? At the moment, the only way I can see to do this is to use EM_GETLINE to get line number x, then use EM_FINDTEXT on that returned string, then erase all chars from 0 to the return value of EM_FINDTEXT. But that seems way too backwards and hacky. So, is there anything to do what I need here, or will I have to stick to my horrible, hacky method?

Share this post


Link to post
Share on other sites
I haven't used RichEdit in a long time, but IIRC you can access it independent of "lines" (i.e. perform read/write operations on a selection of text, as defined by a starting and ending index). You could read from index 0 until you have found X line returns, then do a replace operation of that selection with ""

Share this post


Link to post
Share on other sites
Quote:
Original post by Michalson
I haven't used RichEdit in a long time, but IIRC you can access it independent of "lines" (i.e. perform read/write operations on a selection of text, as defined by a starting and ending index). You could read from index 0 until you have found X line returns, then do a replace operation of that selection with ""
Wouldn't using EM_FINDTEXT be just as fast? I think I'll go with that until I find a better method.
Most of the time I'll only be erasing 1 or 2 lines anyway.

EDIT: My method sucked. I'm reading 1 line at a time, and counting the number of chars in it to get a "char from line" indicator. That seems to work perfectly.
Thanks for the suggestion.

[Edited by - Evil Steve on March 29, 2005 10:00:59 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this