SettingDlg.cpp
资源名称:vc_demo.rar [点击查看]
上传用户:zcy791212
上传日期:2013-03-06
资源大小:196k
文件大小:4k
源码类别:
Modem编程
开发平台:
Visual C++
- // SettingDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "vc_demo.h"
- #include "SettingDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSettingDlg dialog
- CSettingDlg::CSettingDlg(CWnd* pParent /*=NULL*/,int tabindex,BOOL Enabled)
- : CDialog(CSettingDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSettingDlg)
- m_bSaveToLog = FALSE;
- m_iLogItemCount = _T("");
- m_iOffLineTime = _T("");
- m_iPollTime = _T("");
- m_iServerPort = _T("");
- m_bSysAutoPoll = FALSE;
- m_bShowHead = FALSE;
- m_bHexShow = FALSE;
- //}}AFX_DATA_INIT
- m_tabindex=tabindex;
- m_BEnabled=Enabled;
- }
- void CSettingDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSettingDlg)
- DDX_Check(pDX, IDC_CKSAVETOLOG, m_bSaveToLog);
- DDX_CBString(pDX, IDC_CMLOGITEMCOUNT, m_iLogItemCount);
- DDX_CBString(pDX, IDC_CMOFFLINETIME, m_iOffLineTime);
- DDX_CBString(pDX, IDC_CMPOLLTIME, m_iPollTime);
- DDX_CBString(pDX, IDC_CMSERVERPORT, m_iServerPort);
- DDX_Check(pDX, IDC_CKSYSAUTOPOLL, m_bSysAutoPoll);
- DDX_Control(pDX, IDC_TAB1, m_tab);
- DDX_Check(pDX, IDC_CKSHOWHEAD, m_bShowHead);
- DDX_Check(pDX, IDC_CKHEXSHOW, m_bHexShow);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSettingDlg, CDialog)
- //{{AFX_MSG_MAP(CSettingDlg)
- ON_WM_SHOWWINDOW()
- ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
- ON_BN_CLICKED(IDC_CKSAVETOLOG, OnCksavetolog)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSettingDlg message handlers
- void CSettingDlg::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- CDialog::OnShowWindow(bShow, nStatus);
- CImageList img;
- img.Create(IDB_SETTING,16,0,RGB(244, 247, 14));
- this->m_tab.SetImageList(&img);
- img.Detach();
- this->m_tab.InsertItem(TCIF_TEXT | TCIF_IMAGE,0,"服务参数",0,NULL);
- this->m_tab.InsertItem(TCIF_TEXT | TCIF_IMAGE,1,"数据处理",1,NULL);
- this->m_tab.SetCurSel(m_tabindex);
- this->ShowItem();
- if (!this->m_bSaveToLog)
- ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->EnableWindow(FALSE);
- ((CComboBox *)GetDlgItem(IDC_CMSERVERPORT))->EnableWindow(m_BEnabled);
- ((CComboBox *)GetDlgItem(IDC_CMPOLLTIME))->EnableWindow(m_BEnabled);
- ((CComboBox *)GetDlgItem(IDC_CMOFFLINETIME))->EnableWindow(m_BEnabled);
- ((CButton *)GetDlgItem(IDC_CKSYSAUTOPOLL))->EnableWindow(m_BEnabled);
- }
- void CSettingDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- m_tabindex=this->m_tab.GetCurSel();
- this->ShowItem();
- *pResult = 0;
- }
- void CSettingDlg::ShowItem()
- {
- if (0==m_tabindex)
- {
- ((CStatic *)GetDlgItem(IDC_STATIC1))->SetWindowText("服务端口");
- ((CStatic *)GetDlgItem(IDC_STATIC2))->SetWindowText("轮询时间");
- ((CStatic *)GetDlgItem(IDC_STATIC3))->SetWindowText("下线时间");
- ((CComboBox *)GetDlgItem(IDC_CMSERVERPORT))->ShowWindow(SW_SHOW);
- ((CComboBox *)GetDlgItem(IDC_CMPOLLTIME))->ShowWindow(SW_SHOW);
- ((CComboBox *)GetDlgItem(IDC_CMOFFLINETIME))->ShowWindow(SW_SHOW);
- ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->ShowWindow(SW_HIDE);
- ((CButton *)GetDlgItem(IDC_CKSYSAUTOPOLL))->ShowWindow(SW_SHOW);
- ((CButton *)GetDlgItem(IDC_CKSAVETOLOG))->ShowWindow(SW_HIDE);
- ((CButton *)GetDlgItem(IDC_CKSHOWHEAD))->ShowWindow(SW_HIDE);
- ((CButton *)GetDlgItem(IDC_CKHEXSHOW))->ShowWindow(SW_HIDE);
- }
- else
- {
- ((CStatic *)GetDlgItem(IDC_STATIC1))->SetWindowText("日志数量");
- ((CStatic *)GetDlgItem(IDC_STATIC2))->SetWindowText("");
- ((CStatic *)GetDlgItem(IDC_STATIC3))->SetWindowText("");
- ((CComboBox *)GetDlgItem(IDC_CMSERVERPORT))->ShowWindow(SW_HIDE);
- ((CComboBox *)GetDlgItem(IDC_CMPOLLTIME))->ShowWindow(SW_HIDE);
- ((CComboBox *)GetDlgItem(IDC_CMOFFLINETIME))->ShowWindow(SW_HIDE);
- ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->ShowWindow(SW_SHOW);
- ((CButton *)GetDlgItem(IDC_CKSYSAUTOPOLL))->ShowWindow(SW_HIDE);
- ((CButton *)GetDlgItem(IDC_CKSAVETOLOG))->ShowWindow(SW_SHOW);
- ((CButton *)GetDlgItem(IDC_CKSHOWHEAD))->ShowWindow(SW_SHOW);
- ((CButton *)GetDlgItem(IDC_CKHEXSHOW))->ShowWindow(SW_SHOW);
- }
- }
- void CSettingDlg::OnCksavetolog()
- {
- CButton *ck;
- ck=(CButton *)GetDlgItem(IDC_CKSAVETOLOG);
- if (1==ck->GetCheck())
- {
- ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->EnableWindow(TRUE);
- }
- else
- {
- ((CComboBox *)GetDlgItem(IDC_CMLOGITEMCOUNT))->EnableWindow(FALSE);
- }
- }