MyTabCtrl.cpp
上传用户:pumpssky
上传日期:2007-12-07
资源大小:110k
文件大小:3k
- // MyTabCtrl.cpp : implementation file
- //
- #include "stdafx.h"
- #include "gmark.h"
- #include "MyTabCtrl.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMyTabCtrl
- CMyTabCtrl::CMyTabCtrl()
- {
- m_DialogID[0] =IDD_DIALOG_MONITOR;
- m_DialogID[1] =IDD_DIALOG_OPERATE;
- m_DialogID[2] =IDD_DIALOG_SETUP;
- m_DialogID[3] =IDD_DIALOG_ADVANCE;
- m_Dialog[0] = new CMonitorDlg();
- m_Dialog[1] = new COperateDlg();
- m_Dialog[2] = new CSetupDlg();
- m_Dialog[3] = new CAdvanceDlg();
- m_nPageCount = 4;
- }
- CMyTabCtrl::~CMyTabCtrl()
- {
- delete m_Dialog[0];
- delete m_Dialog[1];
- delete m_Dialog[2];
- delete m_Dialog[3];
- }
- BEGIN_MESSAGE_MAP(CMyTabCtrl, CTabCtrl)
- //{{AFX_MSG_MAP(CMyTabCtrl)
- ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnSelchange)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyTabCtrl message handlers
- //This function creates the Dialog boxes once
- void CMyTabCtrl::InitDialogs()
- {
- m_Dialog[0]->Create(m_DialogID[0],GetParent());
- m_Dialog[1]->Create(m_DialogID[1],GetParent());
- m_Dialog[2]->Create(m_DialogID[2],GetParent());
- m_Dialog[3]->Create(m_DialogID[3],GetParent());
- }
- //Selection change event for the class derived from CTabCtrl
- void CMyTabCtrl::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- ActivateTabDialogs();
- *pResult = 0;
- }
- void CMyTabCtrl::ActivateTabDialogs()
- {
- int nSel = GetCurSel();
- if(m_Dialog[nSel]->m_hWnd)
- m_Dialog[nSel]->ShowWindow(SW_HIDE);
- CRect l_rectClient;
- CRect l_rectWnd;
- GetClientRect(l_rectClient);
- AdjustRect(FALSE,l_rectClient);
- GetWindowRect(l_rectWnd);
- GetParent()->ScreenToClient(l_rectWnd);
- l_rectClient.OffsetRect(l_rectWnd.left,l_rectWnd.top);
- for(int nCount=0; nCount < m_nPageCount; nCount++){
- m_Dialog[nCount]->SetWindowPos(&wndTop, l_rectClient.left, l_rectClient.top,
- l_rectClient.Width(), l_rectClient.Height(), SWP_HIDEWINDOW);
- }
- m_Dialog[nSel]->SetWindowPos(&wndTop, l_rectClient.left, l_rectClient.top,
- l_rectClient.Width(), l_rectClient.Height(), SWP_SHOWWINDOW);
- m_Dialog[nSel]->ShowWindow(SW_SHOW);
- }
- CMonitorDlg * CMyTabCtrl::GetMonitorDlg()
- {
- return (CMonitorDlg *)m_Dialog[0];
- }
- COperateDlg * CMyTabCtrl::GetOperateDlg()
- {
- return (COperateDlg *)m_Dialog[1];
- }
- CSetupDlg * CMyTabCtrl::GetSetupDlg()
- {
- return (CSetupDlg *)m_Dialog[2];
- }
- CAdvanceDlg * CMyTabCtrl::GetAdvanceDlg()
- {
- return (CAdvanceDlg *)m_Dialog[3];
- }