📄 tabctrl.cpp
字号:
// Tabctrl.cpp : implementation file
//
#include "stdafx.h"
#include "TAB.h"
#include "Tabctrl.h"
#include "Page1.h"
#include "Page2.h"
#include "Page3.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTabctrl
CTabctrl::CTabctrl()
{
m_tabPages[0]=new CPage1;
m_tabPages[1]=new CPage2;
m_tabPages[2]=new CPage3;
m_nNumberOfPages=3;
}
CTabctrl::~CTabctrl()
{
for(int nCount=0; nCount < m_nNumberOfPages; nCount++)
{
delete m_tabPages[nCount];
}
}
void CTabctrl::Init()
{
m_tabCurrent=0;
m_tabPages[0]->Create(IDD_PAGE1, this);
m_tabPages[1]->Create(IDD_PAGE2, this);
m_tabPages[2]->Create(IDD_PAGE3, this);
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
m_tabPages[2]->ShowWindow(SW_HIDE);
SetRectangle();
}
void CTabctrl::SetRectangle()
{
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-1;
nYc=tabRect.bottom-nY-1;
m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
for(int nCount=1; nCount < m_nNumberOfPages; nCount++)
{
m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}
}
BEGIN_MESSAGE_MAP(CTabctrl, CTabCtrl)
//{{AFX_MSG_MAP(CTabctrl)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTabctrl message handlers
void CTabctrl::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CTabCtrl::OnLButtonDown(nFlags, point);
if(m_tabCurrent != GetCurFocus())
{
m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
m_tabCurrent=GetCurFocus();
m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
m_tabPages[m_tabCurrent]->SetFocus();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -