18,363
社区成员




LONG CSCOMMDlg::OnCommunication(WPARAM ch, LPARAM port)
{
/*
if (port <= 0 || port > 4)
return -1;
rxdatacount++; //接收的字节计数
CString strTemp;
strTemp.Format("%ld",rxdatacount);
strTemp="RX:"+strTemp;
m_ctrlRXCOUNT.SetWindowText(strTemp); //显示接收计数
if(m_bStopDispRXData) //如果选择了“停止显示”接收数据,则返回
return -1; //注意,这种情况下,计数仍在继续,只是不显示
//若设置了“自动清空”,则达到50行后,自动清空接收编辑框中显示的数据
if((m_ctrlAutoClear.GetCheck())&&(m_ctrlReceiveData.GetLineCount()>=50))
{
m_ReceiveData.Empty();
UpdateData(FALSE);
}
//如果没有“自动清空”,数据行达到400后,也自动清空
//因为数据过多,影响接收速度,显示是最费CPU时间的操作
if(m_ctrlReceiveData.GetLineCount()>400)
{
m_ReceiveData.Empty();
m_ReceiveData="***The Length of the Text is too long, Emptied Automaticly!!!***\r\n";
UpdateData(FALSE);
}
*/
//如果选择了"十六进制显示",则显示十六进制值
CString str;
// char *p;
if(m_ctrlHexReceieve.GetCheck())
{
str.Format("%02X ",ch);
}
else
{
str.Format("%c",ch);
}
//以下是将接收的字符加在字符串的最后,这里费时很多
//但考虑到数据需要保存成文件,所以没有用List Control
int nLen=m_ctrlReceiveData.GetWindowTextLength();
m_ctrlReceiveData.SetSel(nLen, nLen);
m_ctrlReceiveData.ReplaceSel(str);
nLen+=str.GetLength();
m_ReceiveData=str;
// m_ReceiveData.Empty();
return 0;
}