//MSCommDlg. CPP: implementation file
//
# include "stdafx. H"
# include "MSComm. H"
# include "MSCommDlg. H"
# ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
The static char THIS_FILE []=__FILE__;
# endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlg dialog informs the for App About
The class CAboutDlg: public CDialog
{
Public:
CAboutDlg ();
//Dialog Data
//{{AFX_DATA (CAboutDlg)
Enum {IDD=IDD_ABOUTBOX};
//}} AFX_DATA
//ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL (CAboutDlg)
Protected:
Virtual void DoDataExchange (CDataExchange * symbol;//(DDX/DDV support
//}} AFX_VIRTUAL
//Implementation
Protected:
//{{AFX_MSG (CAboutDlg)
//}} AFX_MSG
DECLARE_MESSAGE_MAP ()
};
CAboutDlg: : CAboutDlg () : CDialog CAboutDlg: : (IDD)
{
//{{AFX_DATA_INIT (CAboutDlg)
//}} AFX_DATA_INIT
}
Void CAboutDlg: : DoDataExchange (CDataExchange * symbol)
{
CDialog: : DoDataExchange (symbol);
//{{AFX_DATA_MAP (CAboutDlg)
//}} AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP (CAboutDlg CDialog)
//{{AFX_MSG_MAP (CAboutDlg)
//No message handlers
//}} AFX_MSG_MAP
END_MESSAGE_MAP ()
/////////////////////////////////////////////////////////////////////////////
//CMSCommDlg dialog
CMSCommDlg: : CMSCommDlg (pParent/*=NULL CWnd * */)
: CDialog (CMSCommDlg: : IDD, pParent)
{
//{{AFX_DATA_INIT (CMSCommDlg)
M_strTXData=https://bbs.csdn.net/topics/_T (" ");
M_strRXData=https://bbs.csdn.net/topics/_T (" ");
//}} AFX_DATA_INIT
//Note that LoadIcon does not require a subsequent DestroyIcon in Win32
M_hIcon=AfxGetApp () - & gt; LoadIcon (IDR_MAINFRAME);
}
Void CMSCommDlg: : DoDataExchange (CDataExchange * symbol)
{
CDialog: : DoDataExchange (symbol);
//{{AFX_DATA_MAP (CMSCommDlg)
DDX_Control (symbol, IDC_STOPBITS m_cStopBits);
DDX_Control (symbol, IDC_PORT m_cPort);
DDX_Control (symbol, IDC_PARITY, m_cParity);
DDX_Control (symbol, IDC_DATABITS m_cDataBits);
DDX_Control (symbol, IDC_BAUD m_cBaud);
DDX_Control (symbol, IDC_MSCOMM1 m_ctrlComm);
DDX_Text (symbol, IDC_EDIT_TXDATA m_strTXData);
DDX_Text (symbol, IDC_EDIT_RXDATA m_strRXData);
//}} AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP (CMSCommDlg CDialog)
//{{AFX_MSG_MAP (CMSCommDlg)
ON_WM_SYSCOMMAND ()
ON_WM_PAINT ()
ON_WM_QUERYDRAGICON ()
ON_BN_CLICKED (IDC_BUTTON_MANUALSEND OnButtonManualsend)
ON_BN_CLICKED (IDC_BUTTON1 OnButton1)
ON_CBN_SELCHANGE (IDC_PORT OnSelchangePort)
ON_CBN_SELCHANGE (IDC_BAUD OnSelchangeBaud)
ON_CBN_SELCHANGE (IDC_DATABITS OnSelchangeDatabits)
ON_CBN_SELCHANGE (IDC_STOPBITS OnSelchangeStopbits)
ON_CBN_SELCHANGE (IDC_PARITY OnSelchangeParity)
//}} AFX_MSG_MAP
END_MESSAGE_MAP ()
/////////////////////////////////////////////////////////////////////////////
//CMSCommDlg message handlers
BOOL CMSCommDlg: : OnInitDialog ()
{
CDialog: : OnInitDialog ();
//Add "About... "Menu item to system menu.
//IDM_ABOUTBOX must be in the system command range.
ASSERT ((IDM_ABOUTBOX & amp; 0==IDM_ABOUTBOX xfff0));
ASSERT (IDM_ABOUTBOX & lt; 0 xf000);
CMenu * pSysMenu=GetSystemMenu (FALSE);
If (pSysMenu!=NULL)
{
Cstrings strAboutMenu;
StrAboutMenu. LoadString (IDS_ABOUTBOX);
if (! StrAboutMenu. IsEmpty ())
{
PSysMenu - & gt; The AppendMenu (MF_SEPARATOR);
PSysMenu - & gt; AppendMenu (MF_STRING IDM_ABOUTBOX, strAboutMenu);
}
}
//Set the icon for this dialog. The framework does this automatically
//when the application 's main window is not a dialog
SetIcon (m_hIcon, TRUE);//Set the big icon
SetIcon (m_hIcon, FALSE);//Set the small icon
//TODO: Add extra initialization here
M_cPort. SetCurSel (0);
M_cBaud. SetCurSel (0);
M_cDataBits. SetCurSel (0);
M_cStopBits. SetCurSel (0);
M_cParity. SetCurSel (0);
If (m_ctrlComm GetPortOpen ())
{
M_ctrlComm. SetPortOpen (false);//close a serial port
SetDlgItemText (IDC_BUTTON1, "open the serial port");
}
M_ctrlComm. SetCommPort (1);//open the software default to COM1 serial port
if(! M_ctrlComm. GetPortOpen ())
{
M_ctrlComm. SetPortOpen (TRUE);//open the serial port
SetDlgItemText (IDC_BUTTON1, "close serial port");
}
The else
{
AfxMessageBox (" always open a serial port ");
}
M_ctrlComm. SetSettings (" 9600, n, 8, 1 ");//open the software to set the default port is 9600 baud rate, no parity, 8 bits of data, one stop bit
M_ctrlComm. SetInputMode (1);//1: detect the data in a binary way
M_ctrlComm. SetRThreshold (1);//parameter 1 said whenever in the serial receive buffer will trigger more than or equal to 1 string receiving data OnComm event
M_ctrlComm. SetInputLen (0);//set the current receiving area data length of 0
M_ctrlComm. GetInput ();//to proofread the first buffer to remove residual data
Return TRUE;//return TRUE unless you set the focus to a control
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull