CoolTabCtrl.h
上传用户:sunh8215
上传日期:2010-02-13
资源大小:1616k
文件大小:4k
- /*####################################################################
- Filename: cooltabctrl.h
- ----------------------------------------------------
- Remarks: ...
- ----------------------------------------------------
- ####################################################################*/
- #if !defined(_ANYOU_COOL_TABCTRL_H)
- #define _ANYOU_COOL_TABCTRL_H
- #if _MSC_VER > 1000
- #pragma once
- #endif
- #include <afxtempl.h>
- #define TABMODE_NONE 0
- #define TABMODE_GROUP 1
- #define TABMODE_TOPTAB 2
- #define TABMODE_BOTTOMTAB 3
- #define TABMODE_LEFTAB 4
- #define TABMODE_RIGHTTAB 5
- /*####################################################################
- ------------------------------------------------
- class CTabPageItem
- ------------------------------------------------
- ####################################################################*/
- class CTabPageItem
- {
- friend class CCoolTabCtrl;
- private:
- CWnd* m_pWnd; //窗口,可以为NULL
- CCoolTabCtrl* m_pParentWnd;
- UINT m_dwState; //窗口类型,0:普通,1:对话框
- CString m_strText; //标签
- HICON m_hIcon; //图标
- CRect m_rect; //矩形区域
- int m_nNumber; //序号
-
- public:
- ~CTabPageItem();
- void OnDraw(CDC *pDC, int nState);
- void Hide();
- CTabPageItem(CCoolTabCtrl* pParentWnd, CWnd* pWnd, const CString &strText, int nNumber);
- void SetRect(const CRect& rect);
- void Expend();
- void SetIcon(HICON hicon);
- protected:
- CRect m_rcLabel;
- };
- /*####################################################################
- ------------------------------------------------
- class CCoolTabCtrl
- ------------------------------------------------
- ####################################################################*/
- class CCoolTabCtrl : public CWnd
- {
- friend class CTabPageItem;
- // Construction--------------------------------------
- DECLARE_DYNCREATE(CCoolTabCtrl)
- public:
- CCoolTabCtrl();
- virtual ~CCoolTabCtrl();
- BOOL Create(const CRect &rect, CWnd *pParentWnd, UINT dwStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
- UINT dwCtrlStyle = 0, UINT nID = 0);
- // Attributes-----------------------------------------
- public:
- void SetActivePage(int nindex);
- void SetBorderStyle(DWORD dwStyle);
- void SetCtrlStyle(DWORD dwStyle);
- int GetActivePage() { return m_nActivePage;}
-
- // Operations-----------------------------------------
- public:
- BOOL AddPage(CWnd* pwnd, LPCTSTR strText, UINT IconID);
- BOOL AddPage(CRuntimeClass* pClass,UINT nIDTemplate, LPCTSTR strText, UINT IconID);
-
- // Overrides------------------------------------------
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CCoolTabCtrl)
- //}}AFX_VIRTUAL
- // Implementation-------------------------------------
- public:
- void DrawBoder(CDC* pDC, CRect rect);
- CWnd* GetPage(int number);
- void SetMode(int nMode);
- void AutoSize();
- BOOL PlayResource(WORD wResourceID);//点击非客户区播放声音
- public:
- // static bool m_bDefaultPage;//是否为缺省的页面
- // Generated message map functions---------------------
- protected:
- int m_nMode;
- //{{AFX_MSG(CCoolTabCtrl)
- afx_msg void OnPaint();
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnNcPaint();
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
- afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
- afx_msg UINT OnNcHitTest(CPoint point);
- afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- private:
- int m_nHotItem;
- DWORD m_dwBorderStyle;
- int m_nActivePage;
- CFont m_fontWnd;
- DWORD m_dwStyle;
- CArray<CTabPageItem*, CTabPageItem*> m_aTabPage;
- };
- //{{AFX_INSERT_LOCATION}}
- #endif // !defined(_ANYOU_COOLTABCTRL_H)