描述:
发现串口已经打开,但是不能接收数据。
项目是在CFormView类基础上作的,对CMSComm m_Comm的操作
只有下面的代码,其他没有了,问题在什么地方,请大侠指点。
int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFormView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
DWORD style=WS_VISIBLE;
if(!m_Comm.Create(NULL,style,CRect(0,0,0,0),this,IDC_COMMCTRL))
{
TRACE0("Failed to create OLE Communications Control\n");
return -1;
}
m_Comm.SetCommPort(1);
CString temp;
temp.Format("%d,n,8,1",4800);
m_Comm.SetSettings(temp);
if( !m_Comm.GetPortOpen())
m_Comm.SetPortOpen(TRUE);//打开串口
return 0;
}
BEGIN_EVENTSINK_MAP(CTestView, CFormView)
//{{AFX_EVENTSINK_MAP(CTestView)
ON_EVENT(CTestView, IDC_COMMCTRL, 1 /* OnComm */, OnComm, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CTestView::OnComm()
{
// TODO: Add your control notification handler code here
MessageBox("");
}