I have a RichTextBox in my application that receives messages asynchronously
from a background timer. As new messages are received, the new message is
added to the RichTextBox. I then want the new lines to be visible.
I found that the RichTextBox must have focus for this to work, so I wrote
the following code:
m_wMsgRTF.SelectionStart = m_wMsgRTF.TextLength + 1;
m_wMsgRTF.SelectionLength = 0;
This seems to work when the form that contains the RichTextBox has focus,
but does not if the form doesn't have focus. However, when you click on the
window, it then scrolls automatically to the correct position - kind of like
it's delaying the action until the parent form has focus, then it handles
the scroll (very irritating).
I want to be able to monitor messages entering the window without having to
go click it each time since another working window has focus 90% of the
time. Is there something I'm doing wrong, or is the a bug or what?
Also, is there a simpler way to force the RichTextBox to scroll to the