MFC中的CTabCtrl控件用起来特别麻烦,封装一下,使制作多页面程序更加方便。
.h文件
#pragma once
#include "vector"
using namespace std;
#define MAX_PAGES 1000
struct pages
{
CDialog *m_pages;
UINT m_IDD;
CString m_title;
};
class CTabSheet : public CTabCtrl
{
DECLARE_DYNAMIC(CTabSheet)
public:
CTabSheet();
virtual ~CTabSheet();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult);
BOOL DeletePage(CString szTitle);
BOOL DeletePage(UINT site);
BOOL AddPage(CString szTitle, CDialog * pDialog, UINT ID,bool ShowFirst = true);
void SetRect(UINT nIdx);
public:
UINT m_PageNum;
vector <pages> m_TabPages;
UINT m_nCurrentPage;
};
.cpp文件
#i