This article was contributed by MB.
Environment: VC5/6 win95/98
I’m looking for Visual C++ 5.0 style menu bar,
but most of products require MSIE4 or a new comctrl32.dll(don’t encourage me do update) .
So I’ve made a class called CMenuBar which don’t use any common controls.
To use CMenuBar in a MFC application, you have to perform the following steps.
1. #include “MenuBar.h” in either StdAfx.h or MainFrm.h
2. Add CMenuBar m_wndMenuBar; to CMainFrame class
3. Add a following code to CMainFrame::OnCreate
if (!m_wndMenuBar.CreateEx(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_RAISEDBORDER) ||
TRACE0(“Failed to create menubar\n”);
return -1; // failed to create
4. Add a following code to CMainFrame::OnCreate after CStatusBar::Create and before
CToolBar::EnableDocking and any other CMainFrame::EnableDocking.
5. Overide PreTranslateMessage in CMainFrame with a following code
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
Update History : July 01, 1999 First submitted to CodeGuru. July 11, 1999 Posted on CodeGuru site. Fatal hanged up problem fixed. (I guess CMenuBar::SizeMenuBar had entered endless loop). Support a MDI application. Crash in debug mode fixed by Mark Gentry.Thanks! Gripper graphics changed a little. Rewrite most of codes. Use the latest CSubclassWnd. October 06, 1999 version 2.08 Cope with MFC6.(gripper graphics is changed.) Cope with CReBar easily. Insist own dock line by CMenuBar::EnableDockingEx. November 13, 1999 version 2.10 CMenuDockBar fixed December 02, 1999 version 2.12 Support OLE menu
Known Problems : Can't determine a direction of popupmenu as MSIE5 can't. (please check out _ComputeMenuTrackPoint) OLE menu support is not enough, but I can't add 5000 lines for perfect support.
Special Thanks to : Paul DiLascia an MSJ columnist This article is based on his *PixieLib*.