Download demo project - 35 Kb

Introduction
MS Visual studio and MS Office products have menus with bitmaps next to
commands which are associated with toolbar buttons. The aim of this class was to
provide a quick and easy method of implementing these types of menus. The menu
class can be used to replace the mainframe window menu as well being used as a
context menu.
Implemention
Files:
- ToolBarWrapper.h & ToolBarWrapper.cpp (Toolbar resource
wrapper)
- MenuEx.h & MenuEx.cpp (principle Menu class)
Add the above files to your project.
Next add the view header file to your projects header file where the menu is
to be used for instance Mainfrm.h
#include "MenuEx.h"
CMenuEx is the class to be included to implement the menu.
class CMainFrame : public CFrameWnd
{
... Some other code
CMenuEx m_menu;
};
To initialise the menu for a frame window, call CMenuEx::Initialize in the
OnCreate procedure.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_menu.Initialize(IDR_MAINFRAME,this))
return -1;
... Some other code
We now need to provide support for sizing and drawing the menu, the requires
processing the WM_MEASUREITEM and WM_DRAWITEM messages. Use the class wizard to
create the message handlers (Note: You change the message filter option in the
class wizard to Window).
For menu items which use the Radio feature in MFC require this adding to your
project where the SetRadio option is used to update the command user interface.
void CMainFrame::OnUpdateRadioItem3(CCmdUI* pCmdUI)
{
pCmdUI->SetRadio(m_nRadioGroup == 3);
m_menu.SetRadio(pCmdUI,m_nRadioGroup == 3); }
That's it, the next versions will
support the intelligent menus and the new fangled MS Visual Studio 7.0beta
menus.