SettingDlg.cpp
上传用户:zcy791212
上传日期:2013-03-06
资源大小:196k
文件大小:4k
源码类别:

Modem编程

开发平台:

Visual C++

  1. // SettingDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "vc_demo.h"
  5. #include "SettingDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CSettingDlg dialog
  13. CSettingDlg::CSettingDlg(CWnd* pParent /*=NULL*/,int tabindex,BOOL Enabled)
  14. : CDialog(CSettingDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CSettingDlg)
  17. m_bSaveToLog = FALSE;
  18. m_iLogItemCount = _T("");
  19. m_iOffLineTime = _T("");
  20. m_iPollTime = _T("");
  21. m_iServerPort = _T("");
  22. m_bSysAutoPoll = FALSE;
  23. m_bShowHead = FALSE;
  24. m_bHexShow = FALSE;
  25. //}}AFX_DATA_INIT
  26. m_tabindex=tabindex;
  27. m_BEnabled=Enabled;
  28. }
  29. void CSettingDlg::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CSettingDlg)
  33. DDX_Check(pDX, IDC_CKSAVETOLOG, m_bSaveToLog);
  34. DDX_CBString(pDX, IDC_CMLOGITEMCOUNT, m_iLogItemCount);
  35. DDX_CBString(pDX, IDC_CMOFFLINETIME, m_iOffLineTime);
  36. DDX_CBString(pDX, IDC_CMPOLLTIME, m_iPollTime);
  37. DDX_CBString(pDX, IDC_CMSERVERPORT, m_iServerPort);
  38. DDX_Check(pDX, IDC_CKSYSAUTOPOLL, m_bSysAutoPoll);
  39. DDX_Control(pDX, IDC_TAB1, m_tab);
  40. DDX_Check(pDX, IDC_CKSHOWHEAD, m_bShowHead);
  41. DDX_Check(pDX, IDC_CKHEXSHOW, m_bHexShow);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CSettingDlg, CDialog)
  45. //{{AFX_MSG_MAP(CSettingDlg)
  46. ON_WM_SHOWWINDOW()
  47. ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
  48. ON_BN_CLICKED(IDC_CKSAVETOLOG, OnCksavetolog)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CSettingDlg message handlers
  53. void CSettingDlg::OnShowWindow(BOOL bShow, UINT nStatus) 
  54. {
  55. CDialog::OnShowWindow(bShow, nStatus);
  56. CImageList img;
  57. img.Create(IDB_SETTING,16,0,RGB(244, 247, 14));
  58.     this->m_tab.SetImageList(&img);
  59. img.Detach();
  60. this->m_tab.InsertItem(TCIF_TEXT | TCIF_IMAGE,0,"服务参数",0,NULL);
  61. this->m_tab.InsertItem(TCIF_TEXT | TCIF_IMAGE,1,"数据处理",1,NULL);
  62. this->m_tab.SetCurSel(m_tabindex);
  63. this->ShowItem();
  64. if (!this->m_bSaveToLog)
  65.         ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->EnableWindow(FALSE);
  66. ((CComboBox *)GetDlgItem(IDC_CMSERVERPORT))->EnableWindow(m_BEnabled);
  67. ((CComboBox *)GetDlgItem(IDC_CMPOLLTIME))->EnableWindow(m_BEnabled);
  68. ((CComboBox *)GetDlgItem(IDC_CMOFFLINETIME))->EnableWindow(m_BEnabled);
  69. ((CButton   *)GetDlgItem(IDC_CKSYSAUTOPOLL))->EnableWindow(m_BEnabled);
  70. }
  71. void CSettingDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) 
  72. {
  73. // TODO: Add your control notification handler code here
  74. m_tabindex=this->m_tab.GetCurSel();
  75. this->ShowItem();
  76. *pResult = 0;
  77. }
  78. void CSettingDlg::ShowItem()
  79. {    
  80. if (0==m_tabindex)
  81. {
  82. ((CStatic *)GetDlgItem(IDC_STATIC1))->SetWindowText("服务端口");
  83. ((CStatic *)GetDlgItem(IDC_STATIC2))->SetWindowText("轮询时间");
  84. ((CStatic *)GetDlgItem(IDC_STATIC3))->SetWindowText("下线时间");
  85. ((CComboBox *)GetDlgItem(IDC_CMSERVERPORT))->ShowWindow(SW_SHOW);
  86. ((CComboBox *)GetDlgItem(IDC_CMPOLLTIME))->ShowWindow(SW_SHOW);
  87. ((CComboBox *)GetDlgItem(IDC_CMOFFLINETIME))->ShowWindow(SW_SHOW);
  88. ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->ShowWindow(SW_HIDE);
  89. ((CButton *)GetDlgItem(IDC_CKSYSAUTOPOLL))->ShowWindow(SW_SHOW);
  90. ((CButton *)GetDlgItem(IDC_CKSAVETOLOG))->ShowWindow(SW_HIDE);
  91. ((CButton *)GetDlgItem(IDC_CKSHOWHEAD))->ShowWindow(SW_HIDE);
  92. ((CButton *)GetDlgItem(IDC_CKHEXSHOW))->ShowWindow(SW_HIDE);
  93. }
  94. else
  95. {
  96.         ((CStatic *)GetDlgItem(IDC_STATIC1))->SetWindowText("日志数量");
  97. ((CStatic *)GetDlgItem(IDC_STATIC2))->SetWindowText("");
  98. ((CStatic *)GetDlgItem(IDC_STATIC3))->SetWindowText("");
  99. ((CComboBox *)GetDlgItem(IDC_CMSERVERPORT))->ShowWindow(SW_HIDE);
  100. ((CComboBox *)GetDlgItem(IDC_CMPOLLTIME))->ShowWindow(SW_HIDE);
  101. ((CComboBox *)GetDlgItem(IDC_CMOFFLINETIME))->ShowWindow(SW_HIDE);
  102. ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->ShowWindow(SW_SHOW);
  103. ((CButton *)GetDlgItem(IDC_CKSYSAUTOPOLL))->ShowWindow(SW_HIDE);
  104. ((CButton *)GetDlgItem(IDC_CKSAVETOLOG))->ShowWindow(SW_SHOW);
  105. ((CButton *)GetDlgItem(IDC_CKSHOWHEAD))->ShowWindow(SW_SHOW);
  106. ((CButton *)GetDlgItem(IDC_CKHEXSHOW))->ShowWindow(SW_SHOW);
  107. }
  108. }
  109. void CSettingDlg::OnCksavetolog() 
  110. {
  111.     CButton *ck;
  112. ck=(CButton *)GetDlgItem(IDC_CKSAVETOLOG);
  113. if (1==ck->GetCheck())
  114. {
  115. ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->EnableWindow(TRUE);
  116. }
  117. else
  118. {
  119. ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->EnableWindow(FALSE);
  120. }
  121. }