Click here to Skip to main content
12,632,072 members (26,273 online)
Click here to Skip to main content

Stats

211.9K views
5.3K downloads
82 bookmarked
Posted

Automatic Tab Bar for MDI Frameworks

, 3 Jan 2003 Public Domain
A dockable bar containing a tabbed list of open windows
#if !defined(AFX_VIEWMANAGER_H__2A1E6B81_0BC9_11D3_933D_0000F0510AC9__INCLUDED_)
#define AFX_VIEWMANAGER_H__2A1E6B81_0BC9_11D3_933D_0000F0510AC9__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ViewManager.h : header file
//

#include <afxcoll.h>
#include "WindowTabCtrl.h"

// Support for different control bar implementations
#ifndef CCBaseControlBar
#define CCBaseControlBar  CControlBar 
#endif

/////////////////////////////////////////////////////////////////////////////
// CViewManager window

class CViewManager : public CCBaseControlBar
{
	DECLARE_DYNAMIC(CViewManager)

private:
    CSize    m_sizeMin;
    CSize    m_sizeFloat;
	CSize    m_sizeDefault;
	CSize    m_sizeMRU;
	int      m_nLMargin;
	UINT     m_nDockID;
	BOOL     m_bWin2000;  // for the double-stripped gripper

// Construction
public:
	CViewManager();

// Attributes
public:

// Operations
public:
    virtual BOOL Create(LPCTSTR lpszWindowName, CWnd* pParentWnd,
        CSize sizeDefault, UINT nID,
        DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP);
	
	void OnActivateView(const BOOL bActivate, CMDIChildWnd* pView);
	int  GetWindowNum();
	void SetViewName(const TCHAR* cs, CMDIChildWnd* pView);
	void RemoveAll();
	void RemoveView(CMDIChildWnd* pView);
	void AddView(const TCHAR* csName, CMDIChildWnd* pView);

	CMDIChildWnd* GetTabInfo(int nTab, TCHAR* pszLabel = NULL) const;
	
	void SetWin2000(BOOL bWin2000);
	BOOL GetWin2000() const;

// Overrides
	virtual void DoPaint(CDC* pDC);
	virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
	virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
	virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CViewManager)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CViewManager();
	BOOL CreateViewManager(CMDIFrameWnd* pMDIFrameWnd, UINT uID);
	CWindowTabCtrl m_ViewTabCtrl;
    CImageList     m_ViewTabImages;
	BOOL           m_bClosing;

	// Generated message map functions
protected:

	void DrawGripper(CDC* pDC);

	//{{AFX_MSG(CViewManager)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
	afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
	//}}AFX_MSG
    BOOL OnViewManagerToolTip(NMHDR* pTTTStruct, LRESULT* pResult);
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////
// CViewManager inlines

inline void CViewManager::SetWin2000(BOOL bWin2000)
{
	m_bWin2000 = bWin2000;
	Invalidate();
}

inline BOOL CViewManager::GetWin2000()	const
{
	return m_bWin2000;
}


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_VIEWMANAGER_H__2A1E6B81_0BC9_11D3_933D_0000F0510AC9__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication

Share

About the Author

Paul Selormey
Engineer
Japan Japan
Systems Engineer

You may also be interested in...

Pro
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161208.2 | Last Updated 4 Jan 2003
Article Copyright 2000 by Paul Selormey
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid