資源簡介
CtabSheet源代碼 可以很方便的使用tab控件創建屬性頁,具體的過程可參考
http://www.vckbase.com/document/viewdoc/?id=398

代碼片段和文件信息
//#include?“StdAfx.h“
//#include?“TabSheet.h“
//
//TabSheet::TabSheet(void)
//{
//}
//
//TabSheet::~TabSheet(void)
//{
//}
//?TabSheet.cpp?:?implementation?file
//
#include?“stdafx.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;
????m_bHideTab=FALSE;
}
CTabSheet::~CTabSheet()
{
????m_arrayStatusTab.RemoveAll();
????m_pPages.RemoveAll();
????m_IDD.RemoveAll();
????m_title.RemoveAll();
}
BEGIN_MESSAGE_MAP(CTabSheet?CTabCtrl)
????//{{AFX_MSG_MAP(CTabSheet)
????ON_WM_LBUTTONDOWN()
????//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CTabSheet?message?handlers
//將字符串從半角轉到全角(bDBC=FALSE)或從全角轉到半角(bDBC=TRUE)
CString?strConv(const?CString&?strIn?BOOL?bDBC?/*?=?TRUE*/)
{???
????CString?strTmp?=?strIn;???
????LPTSTR?szText;???
????if(!strTmp.IsEmpty())
????{???
????????szText?=?strTmp.GetBuffer(0);???
????????size_t?nLen?=?_tcslen(szText);???
????????if(bDBC)
????????{???
????????????for(size_t?i=0;i ????????????{???
????????????????if(12288==szText[i])???
????????????????????szText[i]?=?32;???
????????????????else
????????????????{???
????????????????????if(szText[i]>65280?&&?szText[i]<65375)???
????????????????????????szText[i]?-=?65248;???
????????????????}???
????????????}???
????????}???
????????else
????????{???
????????????for(size_t?i=0;i ????????????{???
????????????????if(32==szText[i])???
????????????????????szText[i]?=?12288;???
????????????????else
????????????????{???
????????????????????if(szText[i]<127)???
????????????????????????szText[i]?+=?65248;???
????????????????}???
????????????}???
????????}???
????????strTmp.ReleaseBuffer();???
????}???
????return?strTmp;???
}
BOOL?CTabSheet::AddPage(LPCTSTR?title?CDialog?*pDialog?UINT?ID?int?nImage)
{
????int?iIndex?=?static_cast(?m_pPages.Add(pDialog)?);
????m_IDD.Add(ID);
????//m_title.Add(title);
????m_title.Add(strConv(titleFALSE));//將標簽的標題字符串全部轉化成全角字符,以便標簽在左或右時標題能夠豎直排列
????m_pPages[iIndex]->Create(?m_IDD[iIndex]?this?);
????InsertItem(?iIndex?m_title[iIndex]?nImage?);
????SetRect(iIndex);
????m_pPages[iIndex]->ShowWindow(iIndex???SW_HIDE?:?SW_SHOW);
????//**?the?initial?status?is?enabled
????m_arrayStatusTab.Add(TRUE);?
????return?TRUE;
}
void?CTabSheet::SetRect(int?iIndex)
{
????ASSERT(iIndex?
????CRect?tabRect?itemRect;
????int?nX?nY?nXc?nYc;//左、頂、寬、高
????GetClientRect(&tabRect);//獲取整個TAB控件的位置大小。
????GetItemRect(0?&itemRect);//item指的只是標簽頁,因此這里是獲得標簽頁的位置大小
????if?(m_bHideTab)
????{
????????nX=tabRect.left;//使用tabRect.left、tabRect.top即可將各頁顯示的子對話框遮住TAB控件的標簽。
????????nY=tabRect.top;
????????nXc=tabRe
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????11466??2009-09-08?22:04??CTabSheet\TabSheet.cpp
?????文件????????2420??2009-09-08?22:04??CTabSheet\TabSheet.h
?????目錄???????????0??2012-04-20?10:44??CTabSheet\
評論
共有 條評論