DlgComport.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // ComportDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "DlgComport.h"
  5. #include ".\dlgcomport.h"
  6. #include "MainFrm.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CDlgComport property page
  14. IMPLEMENT_DYNCREATE(CDlgComport, CPropertyPage)
  15. CDlgComport::CDlgComport() : CPropertyPage(CDlgComport::IDD)
  16. , m_strUID(_T(""))
  17. , m_strDevName(_T(""))
  18. ,m_strDevArea(_T(""))
  19. , m_nTimeout(0)
  20. , m_nDevAddr(0)
  21. , m_nCommPort(0)
  22. , m_nRate(0)
  23. , m_nCheckCode(0)
  24. , m_nNetIP(0)
  25. , m_nNetPort(0)
  26. , m_nDataBit(0)
  27. , m_nStopBit(0)
  28. , m_strReserved6(_T(""))
  29. , m_strReserved7(_T(""))
  30. , m_strReserved8(_T(""))
  31. , m_strReserved9(_T(""))
  32. , m_strReserved10(_T(""))
  33. , m_nReserved6(0)
  34. , m_nReserved7(0)
  35. , m_nReserved8(0)
  36. , m_nReserved9(0)
  37. , m_nReserved10(0)
  38. , m_bReserved6(FALSE)
  39. , m_bReserved7(FALSE)
  40. , m_bReserved8(FALSE)
  41. , m_bReserved9(FALSE)
  42. , m_bReserved10(FALSE)
  43. {
  44. //{{AFX_DATA_INIT(CDlgComport)
  45. //}}AFX_DATA_INIT
  46. }
  47. CDlgComport::~CDlgComport()
  48. {
  49. }
  50. void CDlgComport::DoDataExchange(CDataExchange* pDX)
  51. {
  52. CPropertyPage::DoDataExchange(pDX);
  53. //{{AFX_DATA_MAP(CDlgComport)
  54. //}}AFX_DATA_MAP
  55. DDX_Text(pDX, IDC_EDT_DEV_UID, m_strUID);
  56. DDX_Text(pDX, IDC_EDT_DEV_NAME, m_strDevName);
  57. DDX_Text(pDX, IDC_EDT_DEV_AREA, m_strDevArea);
  58. DDX_Text(pDX, IDC_EDT_TIMEOUT, m_nTimeout);
  59. DDX_Text(pDX, IDC_EDT_DEV_ADDR, m_nDevAddr);
  60. DDV_MinMaxInt(pDX, m_nDevAddr, 0, 254);
  61. DDX_Text(pDX, IDC_EDT_COMM_PORT, m_nCommPort);
  62. DDV_MinMaxInt(pDX, m_nCommPort, 1, 255);
  63. DDX_CBIndex(pDX, IDC_COMBO_RATE, m_nRate);
  64. DDX_CBIndex(pDX, IDC_COMBO_CHECK_CODE, m_nCheckCode);
  65. DDX_IPAddress(pDX, IDC_IPADDR_DEV, m_nNetIP);
  66. DDX_Text(pDX, IDC_EDT_NET_PORT, m_nNetPort);
  67. DDX_Radio(pDX, IDC_RADIO_DATA_BIT_7, m_nDataBit);
  68. DDX_Radio(pDX, IDC_RADIO_STOP_BIT_0, m_nStopBit);
  69. }
  70. BEGIN_MESSAGE_MAP(CDlgComport, CPropertyPage)
  71. //{{AFX_MSG_MAP(CDlgComport)
  72. //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CDlgComport message handlers
  76. BOOL CDlgComport::OnSetActive()
  77. {
  78. // TODO: 在此添加专用代码和/或调用基类
  79. CPropertySheet* pParent=(CPropertySheet*)GetParent();
  80. pParent->SetWizardButtons(PSWIZB_FINISH|PSWIZB_BACK);
  81. return CPropertyPage::OnSetActive();
  82. }
  83. BOOL CDlgComport::OnInitDialog()
  84. {
  85. CPropertyPage::OnInitDialog();
  86. // TODO: 在此添加额外的初始化
  87. ChangeCtrlState();
  88. return TRUE; // return TRUE unless you set the focus to a control
  89. // 异常: OCX 属性页应返回 FALSE
  90. }
  91. void CDlgComport::ChangeCtrlState( bool bStu2000 )
  92. {
  93. GetDlgItem(IDC_STATIC_NET)->EnableWindow(m_nCommunicateMode == 0 ? FALSE : TRUE);
  94. GetDlgItem(IDC_STATIC_DEV_IP)->EnableWindow(m_nCommunicateMode == 0 ? FALSE : TRUE);
  95. GetDlgItem(IDC_IPADDR_DEV)->EnableWindow(m_nCommunicateMode == 0 ? FALSE : TRUE);
  96. GetDlgItem(IDC_STATIC_NET_PORT)->EnableWindow(m_nCommunicateMode == 0 ? FALSE : TRUE);
  97. GetDlgItem(IDC_EDT_NET_PORT)->EnableWindow(m_nCommunicateMode == 0 ? FALSE : TRUE);
  98. GetDlgItem(IDC_STATIC_COMM)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  99. GetDlgItem(IDC_STATIC_DEV_ADDR)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  100. GetDlgItem(IDC_EDT_DEV_ADDR)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  101. GetDlgItem(IDC_STATIC_COMM_PORT)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  102. GetDlgItem(IDC_EDT_COMM_PORT)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  103. GetDlgItem(IDC_STATIC_DATA_BIT)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  104. GetDlgItem(IDC_RADIO_DATA_BIT_7)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  105. GetDlgItem(IDC_RADIO_DATA_BIT_8)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  106. GetDlgItem(IDC_STATIC_RATE)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  107. GetDlgItem(IDC_COMBO_RATE)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  108. GetDlgItem(IDC_STATIC_STOP_BIT)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  109. GetDlgItem(IDC_RADIO_STOP_BIT_0)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  110. GetDlgItem(IDC_RADIO_STOP_BIT_1)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  111. GetDlgItem(IDC_RADIO_STOP_BIT_2)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  112. GetDlgItem(IDC_STATIC_CHECK_CODE)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  113. GetDlgItem(IDC_COMBO_CHECK_CODE)->EnableWindow(m_nCommunicateMode == 1 ? FALSE : TRUE);
  114. CMainFrame *pMainFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
  115. // if( pMainFrm->m_wndDevice.m_bIsStu2000 )
  116. // {
  117. // GetDlgItem(IDC_STATIC_DEV_ADDR)->EnableWindow(TRUE);
  118. // GetDlgItem(IDC_EDT_DEV_ADDR)->EnableWindow(TRUE);
  119. // }
  120. }
  121. LRESULT CDlgComport::OnWizardBack()
  122. {
  123. // TODO: 在此添加专用代码和/或调用基类
  124. UpdateData( false );
  125. return CPropertyPage::OnWizardBack();
  126. }