Click here to Skip to main content
15,896,207 members
Articles / Desktop Programming / MFC

A ToolBarCtrl Based Menubar Control

Rate me:
Please Sign up or sign in to vote.
4.85/5 (19 votes)
3 Dec 20011 min read 212.7K   4.3K   67  
A ToolBarCtrl based menubar control using CMenuXP
#if !defined(AFX_MenuBarXP_H__C492FD05_285B_11D5_99BD_5254AB339987__INCLUDED_)
#define AFX_MenuBarXP_H__C492FD05_285B_11D5_99BD_5254AB339987__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MenuBarXP.h : header file
//
#include "ToolBarXP.h"

#define	MB_POPUPMENU	WM_USER + 1101

/////////////////////////////////////////////////////////////////////////////
// CMenuBarXP window 

class CMenuBarXP : public CToolBarXP
{
// Construction
public:
	CMenuBarXP();

// Attributes
protected:
	CMenu*		m_pMenu;
	int			m_nItemCount;
	int			m_nPressed;
	POINT		m_ptMouse;
	BOOL		m_bTrack;

	CImageList	m_ilIcons;

//override

// Operations
public:
	BOOL		LoadMenu(CMenu *pMenu);
	void		TrackPopup();
	BOOL		OnMenuInput(MSG* pMsg);
	static LRESULT CALLBACK MenuInputFilter(int nCode, WPARAM wParam, LPARAM lParam);

	BOOL		OpenMenu(UINT nChar);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMenuBarXP)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CMenuBarXP();

	// Generated message map functions
protected:
	//{{AFX_MSG(CMenuBarXP)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
	afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
	afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
	//}}AFX_MSG
	afx_msg LRESULT OnPopupMenu(WPARAM wParam, LPARAM lParam);
	afx_msg void	OnExitMenuLoop(BOOL bTrackPopupMenu);
	afx_msg void	OnEnterMenuLoop(BOOL bTrackPopupMenu);
	DECLARE_MESSAGE_MAP()
};

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

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

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


Written By
China China
I'm a chinese programer living in Shanghai, currently working for a software company whose main business is to deliver computer based testing. Software simulation for computer based testing and certifications is my main responsibility in this company. Execpt for software development, I like out-door activities and photography. I am willing to make friends in China and all over the world, so contact me if you have anything in common with meSmile | :)

Comments and Discussions