Some times it is convenient to use a Rich Edit Control as a scrolling text box. For example when using a Rich edit control as a log output window.
To do this we will need to do 2 things:
1. Make sure the selection in the Rich Edit Control is always visible.
You can change this Rich Edit Control property in both your resource editor and your code.
To do this in the resource editor you will need to set the "No hide selection" property of the Rich Edit Control to "true".
To do this in your code you can call the HideSelection Rich Edit Control member function:
// assuming CRichEditCtrl m_logCtrl; exists ...
// Show the selection and make it permanent
m_logCtrl.HideSelection(FALSE,TRUE);
2. Scroll the control to the last line of text by setting the selection to the last character in text.
To do this you can add the following code after updating the text you want to display:
// assuming CRichEditCtrl m_logCtrl; exists ...
long textLen = m_logCtrl.GetTextLength();
// set selection to last character...
m_logCtrl.SetSel(textLen-1,textLen-1);