Click to See Complete Forum and Search --> : richedit line limit


geoffba
September 22nd, 2003, 11:31 AM
I have developed an application that uses the rich edit control to display all information to the user. It is a serial port terminal application. Everthing works fine except that after running for a long time I seem to hit a limit on the number of lines available. It seems no matter how many times I tell the control to go to the next line it just ignores it. Is there a limit on how many lines the richedit control can display, and if there is how do I delete the first line and move the rest of the data up a line? Thanks in advance.

hankdane
September 23rd, 2003, 07:37 PM
Hi Geoff,

Glad to see you're making progress with your application.

Again, a Rich Edit control doesn't have a concept of lines. It uses lines when rendering contents, but it doesn't think of its own contents as a set of lines, only as a set of characters.

It follows that there cannot be a line limit in a Rich Edit control -- but there is a character limit, and you may have run into this. It is rather large though, so I'm not sure if anything else is going on.

To replace, say, the first line in your control, you would have to figure out where the character positions of the first line is. Then, use EM_REPLACESEL, using an empty string. This will clear out the selection. You have to use EM_SETSEL first, since you cannot pass the position with EM_REPLACESEL. So in your case, you would use EM_GETSEL to get the current posisiont (or maybe you already know it), then use EM_SETSEL, then EM_REPLACESEL to remove the line, then EM_SETSEL again to revert to the previous position. In the last call, remember to adjust positions for the deleted characters.

geoffba
September 26th, 2003, 11:32 AM
Sorry it has taken me so long to respond, but I have been trying to learn this on my own. So I forgot that the richedit control does not care about line numbers only a run of characters. But i am still seeing the problem. What happens is when I detect a carriage return telling me to go to the start of the line delete it and then print on it again in order to do this I have to keep a runnin count of how many characters are on the active line. This works fine. But after running until the richedit control has hit a very large number of characters, the carriage return does not do anything. It simply continues printing where it left of from. To erase the line I simply use the EM_GETSEL, EM_SETSEL, and EM_REPLACESEL in that order. Do you have any ideas why it would stop responding to the messages?