⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menuex.h

📁 网吧管理系统VC源码
💻 H
字号:
// Popup.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CMenuEx window

#ifndef _MENUEX_H__
#define _MENUEX_H__

#define RGB_WHITE         RGB( 255, 255, 255 )

class CMenuEx : public CMenu
{
public:

	// Data for to associate with a menu item
	class CMenuItem
	{
	public:
		CString		m_strMenu;	// Caption
		int			m_nPos;		// Ordinal
		int			m_bRadio;	// MFC Radio Flag
	};
	//end CMenuItem

public:
	
	//Begin class CToolBarWrapper
	class CToolBarWrapper
	{
	public:

		struct CToolBarData
		{
			WORD wVersion;
			WORD wWidth;
			WORD wHeight;
			WORD wItemCount;
			WORD* items() { return (WORD*)(this+1); }
		};

	protected:

		HANDLE			m_hGlobal;		// Handle of resource
		WORD			m_bmHeight;		// Button Height
		WORD			m_bmWidth;		// Button Width
		CImageList		m_imgList;		// Image list
		CToolBarData*	m_pData;		// Pointer to resource
	
	public:
		int FindImagePos(UINT nID)
		{
			int nPos = -1; // Start of with invalid position
			int nAlignment = 0; // Alignment (Total number of ID_SEPARATORS)

			if (m_pData != NULL)
			{
				// Loop down array
				for (int i = 0; i < m_pData->wItemCount; i++)
				{
					if (!m_pData->items()[i])
						nAlignment++; // Count up separators

					if (nID == m_pData->items()[i]) // Match
					{
						nPos = i - nAlignment; // Position of command id in toolbar resource
						break;
					}
				}
			}
			return nPos; // Real image position
		}

		BOOL LoadResource(UINT nResourceID)
		{
			BOOL bRet;

			HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(nResourceID), RT_TOOLBAR);
			HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(nResourceID), RT_TOOLBAR);
			if (hRsrc != NULL)
			{
				m_hGlobal = ::LoadResource(hInst, hRsrc);
				if (m_hGlobal != NULL)
				{
					// Load in data 
					m_pData = (CToolBarData*)LockResource(m_hGlobal);
					if (m_pData)
					{
						m_bmHeight	= m_pData->wHeight;
						m_bmWidth	= m_pData->wWidth;

						// Create resource as image list with correct width.
						m_imgList.Create(nResourceID, m_pData->wWidth,1,RGB(192,192,192)); 
						bRet = TRUE;
					}
				}
			}
			return bRet;
		}

		CToolBarWrapper()
		{
			m_bmHeight	= 0;
			m_bmWidth	= 0;
			m_hGlobal	= NULL;
			m_pData		= NULL;
		}

		~CToolBarWrapper()
		{
			UnlockResource(m_hGlobal);
			FreeResource(m_hGlobal);
		}

		int GetWidth()
		{
			return m_bmWidth;
		}

		int GetHeight()
		{
			return m_bmHeight;
		}

		void SetBkColor(COLORREF crBkColor)
		{
			m_imgList.SetBkColor(crBkColor);
		}

		void DrawByIndex(CDC *pDC,int nIndex,CPoint pt)
		{
			m_imgList.Draw(pDC,nIndex,pt,ILD_NORMAL);
		}

		void DrawByIdentifier(CDC *pDC,UINT nId,CPoint pt)
		{
			int nPos = FindImagePos(nId);
			if (-1 != nPos)
				m_imgList.Draw(pDC,nPos,pt,ILD_NORMAL);
		}
	};
	//end class CToolBarWrapper

public:

	CMenuEx();
	void DrawItem( LPDRAWITEMSTRUCT lpDIS);
	void MeasureItem(CWnd* pWnd,LPMEASUREITEMSTRUCT lpMIS);
	BOOL Initialize(UINT nIDR, CWnd* pParent);
	void SetRadio(CCmdUI* pCmdUI, BOOL bSet);
	BOOL LoadMenu(UINT nId);

	// Attributes
protected:
	WORD			Spacing;
	CToolBarWrapper	m_wrapperToolBar;
	CBitmap			m_bmDot;

// Operations
protected:
	COLORREF GetSemiColor();

	BOOL DrawTick(CDC* pDC,CPoint pt, CRect rcFill, UINT nState);
	BOOL DrawDot(CDC* pDC,CPoint pt, CRect rcFill, UINT nState);

	void SetOwnerMenu(CMenuEx *pMenu);
	void UnSetOwnerMenu(CMenuEx *pMenu);
	void BuildDotBitmap();


// Implementation
public:
	virtual ~CMenuEx();
};


#endif _MENUEX_H__
/////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -