Valhalla Legends Forums Archive | Visual Basic Programming | rtb Text Removal

AuthorMessageTime
Lenny
To minimize memory usage, I need to have a rich text box remove the oldest lines of text (top lines).

I have been told there is a SendMessage api call that will do this, Ive tried searching for it on google but have found nothing...Does anyone know if this is even exists?
March 3, 2004, 8:31 PM
Grok
Yes. Select the text you want to delete. Set it to empty string.

[code]
rtb.SelStart = 1
rtb.SelLength = InStr(rtb.Text, vbCrLf)
rtb.SelText = ""
[/code]

You can keep a line counter in your AddChat for whenever you add text. If that count is greater than the number of lines you want to keep, call the delete line code above and decrement the line count.
March 3, 2004, 9:23 PM
Lenny
Anyone know the arguments to send to the "SendMessage" for highlighting text?

I haven't tested the code Grok posted yet but wouldnt
[code]
rtb.SelStart = 1
[/code]
move the rtbscroll up also?
March 3, 2004, 9:54 PM
Grok
After you have deleted the lines, you put SelStart back to Len(rtb.Text)
March 3, 2004, 10:17 PM
Lenny
The switchting from rtb.SelStart = 1 to rtb.SelStart = Len(rtb.Text) causes a flicker to occur at every add becuase of it moving back in forth...

Is there any other way to remove the text? As I said, there's a rumored SendMessage for the rtb to remove text that I cant seem to find...
March 5, 2004, 2:00 AM
Grok
I'm not familiar with that EM_whatever message for RichEdit boxes. Maybe something new in RichEdit 3.0?

Anyway, you can try locking window updates before removing the lines, then unlocking after you reposition the caret.
March 5, 2004, 4:06 AM

Search