CommSetDlg.cpp
上传用户:seaboy_04
上传日期:2013-02-24
资源大小:284k
文件大小:3k
源码类别:

其他行业

开发平台:

Visual C++

  1. // CommSetDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "TTY.h"
  5. #include "CommSetDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CCommSetDlg dialog
  13. CCommSetDlg::CCommSetDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CCommSetDlg::IDD, pParent)
  15. {
  16. m_nParity = 0;
  17. m_nStopBits = 0;
  18. //{{AFX_DATA_INIT(CCommSetDlg)
  19. m_sBaud = _T("");
  20. m_sDataBits = _T("");
  21. m_bEcho = FALSE;
  22. m_bNewLine = FALSE;
  23. m_sPort = _T("");
  24. //}}AFX_DATA_INIT
  25. }
  26. void CCommSetDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CCommSetDlg)
  30. DDX_Control(pDX, IDC_STOPBITS, m_ctrlStopBits);
  31. DDX_Control(pDX, IDC_PARITY, m_ctrlParity);
  32. DDX_Control(pDX, IDC_PORT, m_ctrlPort);
  33. DDX_Control(pDX, IDC_DATABITS, m_ctrlDataBits);
  34. DDX_Control(pDX, IDC_BAUD, m_ctrlBaud);
  35. DDX_CBString(pDX, IDC_BAUD, m_sBaud);
  36. DDX_CBString(pDX, IDC_DATABITS, m_sDataBits);
  37. DDX_Check(pDX, IDC_ECHO, m_bEcho);
  38. DDX_Check(pDX, IDC_NEWLINE, m_bNewLine);
  39. DDX_CBString(pDX, IDC_PORT, m_sPort);
  40. //}}AFX_DATA_MAP
  41. }
  42. BEGIN_MESSAGE_MAP(CCommSetDlg, CDialog)
  43. //{{AFX_MSG_MAP(CCommSetDlg)
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CCommSetDlg message handlers
  48. BOOL CCommSetDlg::OnInitDialog() 
  49. {
  50. CDialog::OnInitDialog();
  51. // TODO: Add extra initialization here
  52. //对对话框的显示情况进行初始化
  53. m_ctrlPort.AddString(_T("COM1"));
  54. m_ctrlPort.AddString(_T("COM2"));
  55. m_ctrlParity.AddString(_T("NONE"));
  56. m_ctrlParity.AddString(_T("EVEN"));
  57. m_ctrlParity.AddString(_T("ODD"));
  58. m_ctrlParity.SetCurSel(m_nParity);
  59. m_ctrlDataBits.AddString(_T("5"));
  60. m_ctrlDataBits.AddString(_T("6"));
  61. m_ctrlDataBits.AddString(_T("7"));
  62. m_ctrlDataBits.AddString(_T("8"));
  63. m_ctrlBaud.AddString(_T("300"));
  64. m_ctrlBaud.AddString(_T("600"));
  65. m_ctrlBaud.AddString(_T("1200"));
  66. m_ctrlBaud.AddString(_T("2400"));
  67. m_ctrlBaud.AddString(_T("9600"));
  68. m_ctrlBaud.AddString(_T("14400"));
  69. m_ctrlBaud.AddString(_T("19200"));
  70. m_ctrlBaud.AddString(_T("38400"));
  71. m_ctrlBaud.AddString(_T("57600"));
  72. m_ctrlStopBits.AddString(_T("1"));
  73. m_ctrlStopBits.AddString(_T("1.5"));
  74. m_ctrlStopBits.AddString(_T("2"));
  75. m_ctrlStopBits.SetCurSel(m_nStopBits);
  76. GetDlgItem(IDC_PORT)->EnableWindow(!m_bConnected);
  77. return TRUE;  // return TRUE unless you set the focus to a control
  78.               // EXCEPTION: OCX Property Pages should return FALSE
  79. }
  80. //"确定"按钮的响应函数
  81. void CCommSetDlg::OnOK() 
  82. {
  83. // TODO: Add extra validation here
  84. UpdateData(TRUE);
  85. UpdateData(FALSE);
  86. m_nParity = m_ctrlParity.GetCurSel();
  87. m_nStopBits = m_ctrlStopBits.GetCurSel();
  88. CDialog::OnOK();
  89. }