菜鸟有礼了,菜鸟刚学vc,按照例子上的步骤安装上了mscomm控件,并写了代码,如下
void CChuankouDlg::OnOnCommMscomm1()
{
// TODO: Add your control notification handler code here
if(m_comm.GetCommEvent()==2) // receive event
{
COleVariant vVar = m_comm.GetInput();
long length;
HRESULT hResult = SafeArrayGetUBound(vVar.parray, 1, &length);
if (hResult == S_OK)
{
length++;
byte * pReceived;
hResult = SafeArrayAccessData(vVar.parray, (void**)&pReceived);
if(hResult == S_OK)
{
// now using pReceived and length
SafeArrayUnaccessData(vVar.parray);
}
}
}
}
我想当串口接收到数据时弹出提示框,比如串口接收到“1234”,那么
AfxMessageBox("1234");
也就是把m_comm.GetInput();的信息弹出来,菜鸟太笨,不要笑话。