⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabsheet.cpp

📁 周立功WinCE光盘资料
💻 CPP
字号:
// TabSheet.cpp : implementation file
//

#include "stdafx.h"
#include "Magic2410.h"
#include "TabSheet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTabSheet

CTabSheet::CTabSheet()
{
	m_nNumOfPages = 0;
	m_nCurrentPage = 0;
}

CTabSheet::~CTabSheet()
{
}


BEGIN_MESSAGE_MAP(CTabSheet, CTabCtrl)
	//{{AFX_MSG_MAP(CTabSheet)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTabSheet message handlers

BOOL CTabSheet::AddPage(LPCTSTR title, CDialog *pDialog, UINT ID)
{
	if( MAXPAGE == m_nNumOfPages )
		return FALSE;

	m_nNumOfPages++;

	m_pPages[m_nNumOfPages-1] = pDialog;
	m_IDD[m_nNumOfPages-1] = ID;
	m_Title[m_nNumOfPages-1] =(const char *) title;

	return TRUE;
}

int CTabSheet::GetCurSel()
{
	return CTabCtrl::GetCurSel();
}

//DEL void CTabSheet::OnLButtonDown(UINT nFlags, CPoint point)
//DEL {
//DEL 	CTabCtrl::OnLButtonDown(nFlags, point);
//DEL 
//DEL 	if(m_nCurrentPage != GetCurFocus())
//DEL 	{
//DEL 		m_pPages[m_nCurrentPage]->ShowWindow(SW_HIDE);
//DEL 		m_nCurrentPage=GetCurFocus();
//DEL 		m_pPages[m_nCurrentPage]->ShowWindow(SW_SHOW);
//DEL //		m_pPages[m_nCurrentPage]->SetFocus();
//DEL 	}
//DEL }

int CTabSheet::SetCurSel(int nItem)
{
	if( nItem < 0 || nItem >= m_nNumOfPages)
		return -1;

	int ret = m_nCurrentPage;

	if(m_nCurrentPage != nItem )
	{
		m_pPages[m_nCurrentPage]->ShowWindow(SW_HIDE);
		m_nCurrentPage = nItem;
		m_pPages[m_nCurrentPage]->ShowWindow(SW_SHOW);
//		m_pPages[m_nCurrentPage]->SetFocus();
		CTabCtrl::SetCurSel(nItem);
	}

	return ret;
}


void CTabSheet::SetRect()
{
	CRect tabRect, itemRect;
	int nX, nY, nXc, nYc;

	GetClientRect(&tabRect);
	GetItemRect(0, &itemRect);

	nX=itemRect.left;
	nY=itemRect.bottom+1;
	nXc=tabRect.right-itemRect.left-2;
	nYc=tabRect.bottom-nY-2;

	m_pPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
	for( int nCount=1; nCount < m_nNumOfPages; nCount++ )
		m_pPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}

void CTabSheet::Show()
{
	for( int i=0; i < m_nNumOfPages; i++ )
	{
		m_pPages[i]->Create( m_IDD[i], this );
		InsertItem( i, (LPCTSTR)m_Title[i] );
	}

	m_pPages[0]->ShowWindow(SW_SHOW);
	for( i=1; i < m_nNumOfPages; i++)
		m_pPages[i]->ShowWindow(SW_HIDE);

	SetRect();
}


#define ZLG7290_PAGE_NUM	2
#define ADC_PAGE_NUM		3
#define GPRS_PAGE_NUM		6

#include "GPRSMSG.h"

void CTabSheet::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CTabCtrl::OnLButtonDown(nFlags, point);
	CButton *Key;

	if(m_nCurrentPage != GetCurFocus())
	{
		m_pPages[m_nCurrentPage]->ShowWindow(SW_HIDE);
		m_nCurrentPage=GetCurFocus();
		m_pPages[m_nCurrentPage]->ShowWindow(SW_SHOW);
//		m_pPages[m_nCurrentPage]->SetFocus();

		if (m_nCurrentPage == ADC_PAGE_NUM)				/* 当前为 ADC 页面 */
		{				
			// 停止 ZLG7290 定时 
			m_pPages[ZLG7290_PAGE_NUM]->KillTimer(1);	
			Key = (CButton *)m_pPages[ZLG7290_PAGE_NUM]->GetDlgItem(IDC_START_SCAN);
			Key->SetWindowText(_T("开始扫描"));			
			Key->SetCheck(0);							

			// 停止 GPRS 定时
			m_pPages[GPRS_PAGE_NUM]->KillTimer(1);		
		}
		else if (m_nCurrentPage == ZLG7290_PAGE_NUM)	/* 当前为 ZLG7290 页面 */
		{
			// 停止 ADC 定时 
			m_pPages[ADC_PAGE_NUM]->KillTimer(1);	
			Key = (CButton *)m_pPages[ADC_PAGE_NUM]->GetDlgItem(IDC_BUTTON_START_ADC);
			Key->SetWindowText(_T("开始采样"));			
			Key->SetCheck(0);							

			// 停止 GPRS 定时
			m_pPages[GPRS_PAGE_NUM]->KillTimer(1);
		}
		else if (m_nCurrentPage == GPRS_PAGE_NUM)		/* 当前为 GPRS 页面 */
		{
			// 停止 ZLG7290 定时 
			m_pPages[ZLG7290_PAGE_NUM]->KillTimer(1);	
			Key = (CButton *)m_pPages[ZLG7290_PAGE_NUM]->GetDlgItem(IDC_START_SCAN);
			Key->SetWindowText(_T("开始扫描"));			
			Key->SetCheck(0);	

			// 停止 ADC 定时 
			m_pPages[ADC_PAGE_NUM]->KillTimer(1);	
			Key = (CButton *)m_pPages[ADC_PAGE_NUM]->GetDlgItem(IDC_BUTTON_START_ADC);
			Key->SetWindowText(_T("开始采样"));			
			Key->SetCheck(0);

			GPRSMSG *pDlgMsg = (GPRSMSG *)m_pPages[GPRS_PAGE_NUM];
			if (pDlgMsg->GPRSIsOpen)
				m_pPages[GPRS_PAGE_NUM]->SetTimer(1, 1000, NULL);	/* 每 1 秒读取一次短信 */
		}

		if (m_nCurrentPage != ZLG7290_PAGE_NUM)
		{
			// 停止 ZLG7290 定时 
			m_pPages[ZLG7290_PAGE_NUM]->KillTimer(1);	
			Key = (CButton *)m_pPages[ZLG7290_PAGE_NUM]->GetDlgItem(IDC_START_SCAN);
			Key->SetWindowText(_T("开始扫描"));			
			Key->SetCheck(0);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -