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

📄 mytabctrl.cpp

📁 使用RFID的一个监控程序
💻 CPP
字号:
// MyTabCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "MyTabCtrl.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyTabCtrl

CMyTabCtrl::CMyTabCtrl()
{
	m_itemCount=0;
	m_pointWnd.x=1;
	m_pointWnd.y=21;
}

CMyTabCtrl::~CMyTabCtrl()
{
}


BEGIN_MESSAGE_MAP(CMyTabCtrl, CTabCtrl)
	//{{AFX_MSG_MAP(CMyTabCtrl)
	ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnSelChange)
	ON_NOTIFY_REFLECT(TCN_SELCHANGING, OnSelChanging)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyTabCtrl message handlers

void CMyTabCtrl::AddItem(CWnd *pWnd, LPTSTR strName)
{
	TCITEM item;

	item.mask = TCIF_TEXT|TCIF_PARAM;
	item.lParam = (LPARAM)pWnd;
	item.pszText = _T(strName);
	InsertItem(m_itemCount, &item);
	CRect rect;
	GetClientRect(&rect);
		
	rect.top = m_pointWnd.y;
	
	pWnd->SetWindowPos(NULL, m_pointWnd.x, m_pointWnd.y , rect.Width()-m_pointWnd.x, rect.Height()-m_pointWnd.y, 
						SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER);

	if(m_itemCount==0)
		pWnd->ShowWindow(SW_SHOW);
	else
		pWnd->ShowWindow(SW_HIDE);
	m_itemCount++;
}

void CMyTabCtrl::OnSelChange(NMHDR* pNMHDR, LRESULT* pResult) 
{
	int iNewTab = GetCurSel();
	TCITEM item;
	CWnd* pWnd;
	item.mask = TCIF_PARAM;
	//** 显示选中项 --------
	GetItem(iNewTab, &item);
	pWnd = reinterpret_cast<CWnd*> (item.lParam);
	ASSERT_VALID(pWnd);
	pWnd->ShowWindow(SW_SHOW);
	
	*pResult = 0;
}

void CMyTabCtrl::OnSelChanging(NMHDR* pNMHDR, LRESULT* pResult) 
{
	int iNewTab = GetCurSel();
	TCITEM item;
	CWnd* pWnd;
	item.mask = TCIF_PARAM;

	//** 隐藏当前项 ---------
	GetItem(iNewTab, &item);
	pWnd = reinterpret_cast<CWnd*> (item.lParam);
	ASSERT_VALID(pWnd);
	pWnd->ShowWindow(SW_HIDE);
	pWnd->UpdateData(TRUE);
	
	*pResult = 0;
}

⌨️ 快捷键说明

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