Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Lenny on March 03, 2004, 02:31 PM

Title: rtb Text Removal
Post by: Lenny on March 03, 2004, 02:31 PM
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?
Title: Re:rtb Text Removal
Post by: Grok on March 03, 2004, 03:23 PM
Yes.  Select the text you want to delete.  Set it to empty string.


   rtb.SelStart = 1
   rtb.SelLength = InStr(rtb.Text, vbCrLf)
   rtb.SelText = ""


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.
Title: Re:rtb Text Removal
Post by: Lenny on March 03, 2004, 03:54 PM
Anyone know the arguments to send to the "SendMessage" for highlighting text?

I haven't tested the code Grok posted yet but wouldnt

   rtb.SelStart = 1

move the rtbscroll up also?
Title: Re:rtb Text Removal
Post by: Grok on March 03, 2004, 04:17 PM
After you have deleted the lines, you put SelStart back to Len(rtb.Text)
Title: Re:rtb Text Removal
Post by: Lenny on March 04, 2004, 08:00 PM
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...
Title: Re:rtb Text Removal
Post by: Grok on March 04, 2004, 10:06 PM
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.