代码
CMyTabCtrl::CMyTabCtrl()
{
 m_tabPages[
0]=new CTabOne;
 m_tabPages[
1]=new CTabTwo;
 m_tabPages[
2]=new CTabThree;

 m_nNumberOfPages
=3;
}

CMyTabCtrl::
~CMyTabCtrl()
{
 
for(int nCount=0; nCount < m_nNumberOfPages; nCount++){
  delete m_tabPages[nCount];
 }
}

void CMyTabCtrl::Init()
{
 m_tabCurrent
=0;

 m_tabPages[
0]->Create(IDD_TAB_ONE, this);
 m_tabPages[
1]->Create(IDD_TAB_TWO, this);
 m_tabPages[
2]->Create(IDD_TAB_THREE, this);

 m_tabPages[
0]->ShowWindow(SW_SHOW);
 m_tabPages[
1]->ShowWindow(SW_HIDE);
 m_tabPages[
2]->ShowWindow(SW_HIDE);

 SetRectangle();
}

void CMyTabCtrl::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);
 }
}


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

void CMyTabCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
{
 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();
 }
}

 

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2021-07-23
  • 2022-12-23
  • 2021-08-11
  • 2021-11-06
  • 2021-06-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-12
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案