1.设置:
可以将 Vertical Scroll 设置为ture,这样可以拖动要显示的。
2.添加变量
CEdit 的 名字为:m_editMessage
3.代码
str.Format(_T(" sth to display ");
m_editMessage.SetSel(-1,-1);
m_editMessage.ReplaceSel(str + "\r\n");
然后就可以自动换行显示了。
4.问题:
当滚动到一定次数时候,edit不在接收字符,不在滚动了。这个时候
可以将edit 清空
int iLineNum=m_editMessage.GetLineCount();
if(iLineNum<=200)
{
m_editMessage.SetSel(-1, -1);
m_editMessage.ReplaceSel(str+"\r\n\r\n");
}
else
{
m_editMessage.SetSel(0, -1);
m_editMessage.Clear();
}
取自msdn
void SetSel( int nStartChar, int nEndChar, BOOL bNoScroll = FALSE );
Parameters
nStartChar
Specifies the starting position. If nStartChar is 0 and nEndChar is –1, all the text in the edit control is selected. If nStartChar is –1, any current selection is removed.
nEndChar
Specifies the ending position.