描述:
我想写一个这样的控件,方便以后写串口程序时使用起来简单些,可以我遇到了些问题。
我在 CXXXXCtrl类中声明了:CMSComm m_Mscomm;
并在这个类中加入了#include "MSComm.h" (MSComm控件我加入到了工程中)。
我在 工程中我增加了 OpenPort()方法,在这个方法中写下了这些代码:
CXXXXCtl.cpp:
void CCKTXCtrl::OpenPort()
{
// TODO: Add your dispatch handler code here
if(m_Mscomm.GetPortOpen())
{
m_Mscomm.SetPortOpen(FALSE);
}
m_Mscomm.SetCommPort(1);
if(!m_Mscomm.GetPortOpen())
{
m_Mscomm.SetPortOpen(TRUE);
}
else
{
AfxMessageBox("没有打开COM1");
}
m_Mscomm.SetSettings("9600,n,8,1");
m_Mscomm.SetInputMode(1);
m_Mscomm.SetRThreshold(1);
m_Mscomm.SetInputLen(0);
m_Mscomm.GetInput();
}
到这里,串口,算是打开了,可是我在VB中用这个控件的时候就会报这个错:
Debug Assertion Failed!
Program: ......................................
File:winnocc.cpp
Line:345
For information ....................................
问题就是这样的了,请大家帮我看下呀。如果看不清,我可以把程序发给你帮我看下,谢谢了!!!!!!