Click here to Skip to main content
15,886,799 members
Articles / Desktop Programming / MFC

Automatic Tab Bar for MDI Frameworks

Rate me:
Please Sign up or sign in to vote.
4.80/5 (14 votes)
3 Jan 2003Public Domain 245.3K   5.8K   82  
A dockable bar containing a tabbed list of open windows
// PopupMenu.h: interface for the CPopupMenu class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_POPUPMENU_H__F2CEE8B2_014D_11D2_83E4_0000B43382FE__INCLUDED_)
#define AFX_POPUPMENU_H__F2CEE8B2_014D_11D2_83E4_0000B43382FE__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

class CPopupMenu : public CMenu  
{
public:
	struct ToolBarData	
	{
		// struct for toolbar resource; guess you already know it ;)
		WORD wVersion;
		WORD wWidth;			
		WORD wHeight;			
		WORD wItemCount;		
	};
	struct SpawnItem
	{
		int		iImageIdx;
		int		iCmd;
		TCHAR   cText[128];
	};
	struct ImageItem
	{
		int	iImageIdx;
		int	iCmd;
	};

	CPopupMenu();
	virtual ~CPopupMenu();

	HFONT hMenuBoldFont;
	BOOL CreateBoldFont();

	HFONT	hMenuFont, hGuiFont;
	CSize szImage;
	int FindImageItem(const int cmd);

	SpawnItem* AddSpawnItem(const TCHAR* txt, const int cmd);
	void AddImageItem(const int idx, WORD cmd);

	void RemapMenu(CMenu* pMenu);

	CImageList ilList;
	CImageList ilOther;

	COLORREF crMenuText, crMenuTextSel;
	COLORREF cr3dFace, crMenu, crHighlight, cr3dHilight, cr3dShadow, crGrayText;
	COLORREF m_clrBtnFace, m_clrBtnHilight, m_clrBtnShadow;

	int iSpawnItem;
	SpawnItem** pSpawnItem;

	int iImageItem;
	ImageItem* pImageItem;

	BOOL LoadToolBarResource(UINT resId);
	BOOL AddToolBarResource(UINT resId);

	void EnableMenuItems(CMenu* pMenu, CWnd* pParent);

	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);

private:
	BOOL DrawCheckmark(CDC& dc, const CRect& rc, BOOL bSelected);
};

#endif // !defined(AFX_POPUPMENU_H__F2CEE8B2_014D_11D2_83E4_0000B43382FE__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


Written By
Engineer
Japan Japan
Systems Engineer

Comments and Discussions