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

📄 splittab.cpp

📁 VC++中Tab View的多种实现方法
💻 CPP
字号:
// splitTab.cpp : implementation file
//

#include "stdafx.h"
#include "tab.h"

#include "TabView.h"
//#include "wndTab.h"
#include "splitTab.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSplitterTabWnd

IMPLEMENT_DYNCREATE(CSplitterTabWnd, CSplitterWnd)

CSplitterTabWnd::CSplitterTabWnd()
{
   m_cxSplitter    = m_cySplitter    = 0;   // size of splitter bar
   m_cxSplitterGap = m_cySplitterGap = 0;   // amount of space between panes
   m_cxBorder      = m_cyBorder      = 0;   // borders in client area
}

CSplitterTabWnd::~CSplitterTabWnd()
{
}

void CSplitterTabWnd::RecalcLayout()
{
   CWnd* pWnd;
   CRect rectClient;

   GetClientRect( rectClient );

   // Set position for the tab window
   pWnd = GetPane( 1, 0 );

   pWnd->SetWindowPos( this, 
                       rectClient.left,
                       rectClient.bottom - 20,
                       rectClient.right,
                       20,
                       SWP_NOACTIVATE|SWP_NOZORDER );

   // Set position for the working-window
   pWnd = GetPane( 0, 0 );
   pWnd->SetWindowPos( this, 
                       rectClient.left,
                       rectClient.top,
                       rectClient.right,
                       rectClient.bottom - 20, 
                       SWP_NOACTIVATE|SWP_NOZORDER );

}


BOOL CSplitterTabWnd::Create( CWnd* pwndParent, CCreateContext* pContext )
{
   SIZE  size;
   CRect rect;
   
   CreateStatic( pwndParent, 2, 1, WS_CHILD );

   pwndParent->GetClientRect( &rect );
   
   size.cx = rect.right;
   size.cy = rect.bottom - 20;
   
   VERIFY( CreateView( 0, 0, RUNTIME_CLASS(CTabView), size, pContext ) );

   size.cy = 20;
   VERIFY( CreateView( 1, 0, RUNTIME_CLASS(CWndTab), size, pContext ) );

   
   
   ShowWindow( SW_SHOWNORMAL );
   UpdateWindow();

   return TRUE;

}

BEGIN_MESSAGE_MAP(CSplitterTabWnd, CSplitterWnd)
	//{{AFX_MSG_MAP(CSplitterTabWnd)
	ON_WM_LBUTTONDOWN()
	ON_WM_SETCURSOR()
	ON_WM_MOUSEMOVE()
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CSplitterTabWnd::OnLButtonDown(UINT nFlags, CPoint point)
{     
    // prevent the user from dragging the splitter bar
	return;
}

BOOL CSplitterTabWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{   
    // Don't allow the cursor to change over splitbar
	return FALSE;
	
}

void CSplitterTabWnd::OnMouseMove(UINT nFlags, CPoint point)
{       
    // Don't allow the cursor to change over splitbar
    CWnd::OnMouseMove(nFlags, point);
}

void CSplitterTabWnd::OnSize(UINT nType, int cx, int cy) 
{
	//CSplitterWnd::OnSize(nType, cx, cy);

   if (nType != SIZE_MINIMIZED && cx > 0 && cy > 0)
   {
		RecalcLayout();
   }
	
}

⌨️ 快捷键说明

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