怎么点下关闭按钮可以关闭串口?
程序代码:
void CMyScomm2Dlg::OnOpen() { // TODO: Add your control notification handler code here int iPort; CString strTmp,strSet; UpdateData(); m_cmbCom.GetLBText(m_cmbCom.GetCurSel(),strTmp);////获取当前选项的索引及字符串,存入strTmp iPort = atoi(strTmp.Mid(3,(strTmp.GetLength()-3)));//com3,com254 if(m_ctrlComm.GetPortOpen()) m_ctrlComm.SetPortOpen(FALSE); m_ctrlComm.SetCommPort(iPort);//选择com1 if( !m_ctrlComm.GetPortOpen()) { m_ctrlComm.SetPortOpen(TRUE);//打开串口 m_btnOpen.SetWindowText("关闭"); } else AfxMessageBox("cannot open serial port"); m_ctrlComm.SetSettings("9600,n,8,1"); //波特率9600,无校验,8个数据位,1个停止位 m_ctrlComm.SetInputMode(1); //以二进制方式检到数据 m_ctrlComm.SetRThreshold(1); //参数1表示每当串口接收缓冲区中有多于或等于1个字符时将引发一个接收数据的OnComm事件 m_ctrlComm.SetInputLen(0); //设置当前接收区数据长度为0 m_ctrlComm.GetInput();//先预读缓冲区以清除残留数据 }现在可以点下打开,打开串口,打开按钮也会编程关闭,怎么实现点下关闭按钮来关闭串口,求帮忙谢谢!!!