你好,感谢你阅读此帖.我在一个串口通信程序中,使用了一个Edit Box来显示发送和接收的报文.现在我想让这个Edit Box控件只显示固定行数比如100个报文的数据.如何做到?我把我的代码贴上来,大家帮我看看,这段代码最后运行的结果如下图:
以下是我的显示的函数.int rowCount=0;
//////////////////////////////////////////////////////////////////////////
//Buff:传入的字符串
//len:传入的字符串长度
//type:类型,0:接收;1:发送.
//////////////////////////////////////////////////////////////////////////
void CVMobBusDlg::ShowHex(LPSTR Buff, int len, BYTE type)
{
if(m_Pause)
return;
CString sString;
char stemp[4];
if(type)
sString = "发送:";
else
sString = "接收:";

for(int i=0;i<len;i++)
{
sprintf(stemp,"%02x ",(BYTE)Buff[i]);
sString += stemp;
}
sString.MakeUpper();
sString +="\n";
//外部变量
rowCount++;
//m_TEXT是CEdit控件的Control类型变量.
if(rowCount>=25)
{
CString ss;
m_TEXT.GetWindowText(ss);
int n = ss.Find('\n');
m_TEXT.SetSel(0,n-1);
m_TEXT.ReplaceSel("");
rowCount=25;
//  m_TEXT.SetWindowText("");
//  rowCount=0;
}
int length = m_TEXT.GetWindowTextLength();
m_TEXT.SetSel(length,length);
m_TEXT.ReplaceSel(sString);
m_TEXT.LineScroll(m_TEXT.GetLineCount(),0);
}