// SerialParaDlg.cpp : implementation file // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "serialtester.h" #include "SerialParaDlg.h" #include "SerialComm.h" #include "MainDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSerialParaDlg dialog CSerialParaDlg::CSerialParaDlg(CWnd* pParent /*=NULL*/) : CDialog(CSerialParaDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSerialParaDlg) m_BitsPerSec = ""; m_DataBits = ""; m_FlowControl = ""; m_Parity = ""; m_PortUsed = ""; m_StopBits = ""; //}}AFX_DATA_INIT } void CSerialParaDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSerialParaDlg) DDX_CBString(pDX, IDC_COMBO_BITSPERSEC, m_BitsPerSec); DDX_CBString(pDX, IDC_COMBO_DATABITS, m_DataBits); DDX_CBString(pDX, IDC_COMBO_FLOWCONTROL, m_FlowControl); DDX_CBString(pDX, IDC_COMBO_PARITY, m_Parity); DDX_CBString(pDX, IDC_COMBO_PORTUSED, m_PortUsed); DDX_CBString(pDX, IDC_COMBO_STOPBITS, m_StopBits); //}}AFX_DATA_MAP } /* The UseThis method exists only to transfer a pointer to the communication class to this dialog, and is called only once in the program's lifetime. */ void CSerialParaDlg::UseThis(CSerialComm* pCs) { // Assign a direct pointer to the communication class. m_pComms = pCs; } BEGIN_MESSAGE_MAP(CSerialParaDlg, CDialog) //{{AFX_MSG_MAP(CSerialParaDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSerialParaDlg message handlers void CSerialParaDlg::OnOK() { // Make certain that the member variables are up-to-date. UpdateData(TRUE); // Set CSerialComm's setting variables according to the member variables. m_pComms->SetPort(m_PortUsed.operator LPCTSTR()); m_pComms->SetBaudrate(m_BitsPerSec.operator LPCTSTR()); m_pComms->SetDatabits(m_DataBits.operator LPCTSTR()); m_pComms->SetParity(m_Parity.operator LPCTSTR()); m_pComms->SetStopbits(m_StopBits.operator LPCTSTR()); m_pComms->SetHandshaking(m_FlowControl.operator LPCTSTR()); CDialog::OnOK(); } void CSerialParaDlg::OnCancel() { CDialog::OnCancel(); } BOOL CSerialParaDlg::OnInitDialog() { CDialog::OnInitDialog(); // Read CSerialComm's setting variables and set the dialog's member variables accordingly. m_BitsPerSec = _T(m_pComms->GetBaudrate().c_str()); m_DataBits = _T(m_pComms->GetDatabits().c_str()); m_FlowControl = _T(m_pComms->GetHandshaking().c_str()); m_Parity = _T(m_pComms->GetParity().c_str()); m_PortUsed = _T(m_pComms->GetPort().c_str()); m_StopBits = _T(m_pComms->GetStopbits().c_str()); // Make certain that the comboboxes are set to correct values. UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }