//////////////////////////////////////////////////////////////// // 1998 Microsoft Systems Journal. // If this code works, it was written by Paul DiLascia. // If not, I don't know who wrote it. // Compiles with Visual C++ 5.0 on Windows 95 // See DisabTab.cpp // #if !defined CTABCTRLWITHDISABLE #define CTABCTRLWITHDISABLE class CTabCtrlWithDisable : public CTabCtrl { DECLARE_DYNAMIC(CTabCtrlWithDisable) public: CTabCtrlWithDisable(); virtual ~CTabCtrlWithDisable(); // functions you must implement/call virtual bool IsTabEnabled(int iTab) = 0; // you must override BOOL TranslatePropSheetMsg(MSG* pMsg); // call from prop sheet BOOL SubclassDlgItem(UINT nID, CWnd* pParent); // non-virtual override // helpers int NextEnabledTab(int iTab, BOOL bWrap); // get next enabled tab int PrevEnabledTab(int iTab, BOOL bWrap); // get prev enabled tab BOOL SetActiveTab(UINT iNewTab); // set tab (fail if disabled) bool m_bOwnerDraw; protected: DECLARE_MESSAGE_MAP() afx_msg BOOL OnSelChanging(NMHDR* pNmh, LRESULT* pRes); // MFC overrides virtual BOOL PreTranslateMessage(MSG* pMsg); virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); // override to draw text only; eg, colored text or different font virtual void OnDrawText(CDC& dc, CRect rc, CString sText, BOOL bDisabled); }; class CMyTabCtrl : public CTabCtrlWithDisable { public: CMyTabCtrl(); int GetFirstEnableTab(); bool AnyTabEnable(); void DisableTab(int nTab); void EnableTab(int nTab); virtual bool IsTabEnabled(int iTab) { return m_bTabEnable[iTab]; } private: bool m_bTabEnable[20]; }; #endif