There are two ways of doing this:
The first method: Overload the CREATE function of the frame class, as follows:
Copy Code code as follows:
BOOL cmainframe::create (LPCTSTR lpszclassname, LPCTSTR lpszwindowname, DWORD dwstyle, const rect& RECT, CWnd* PParen Twnd, LPCTSTR lpszmenuname, DWORD dwExStyle, ccreatecontext* pContext)
{
TODO: Add private code here and/or call base class
Return CFrameWnd::Create (lpszClassName, lpszWindowName, Dwstyle, rect,////pparentwnd, Lpszmenuname, DwExStyle, PCo ntext);
Hmenu nidorhmenu = NULL;
Return Cframewnd::createex (Dwexstyle,lpszclassname,lpszwindowname,dwstyle,
Rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,
Pparentwnd->getsafehwnd (),
Nidorhmenu,
(LPVOID) pContext);
}
The second method: Manually delete all menu items. Define a function that deletes all menu items first:
Copy Code code as follows:
/*!
* \brief Delete all the menu bars.
*
* Delete all menu bars for the window.
* \return No.
*/
static void Delallmenu (Hmenu hmenu)
{
First remove the extra menu items
int menucount = Getmenuitemcount (hmenu);
for (int i = menucount-1;i>-1;i--)
{
::D Eletemenu (Hmenu,i, mf_byposition);
}
}
This function is then called in the OnCreate function of the framework class, as follows:
Copy Code code as follows:
int CMainFrame::OnCreate (lpcreatestruct lpcreatestruct)
{
if (cframewnd::oncreate (lpcreatestruct) = =-1)
return-1;
if (!m_wndtoolbar.createex (this, Tbstyle_flat, Ws_child | ws_visible | Cbrs_top
| Cbrs_gripper | Cbrs_tooltips | cbrs_flyby | Cbrs_size_dynamic) | |
!m_wndtoolbar.loadtoolbar (IDR_MAINFRAME))
{
TRACE0 ("Failed to create toolbar \ n");
return-1; Failed to create
}
if (!m_wndstatusbar.create) | |
!m_wndstatusbar.setindicators (indicators,
sizeof (indicators)/sizeof (UINT))
{
TRACE0 ("Failed to create status bar \ n");
return-1; Failed to create
}
TODO: Delete These three lines if you don't need the toolbar to dock
M_wndtoolbar.enabledocking (Cbrs_align_any);
EnableDocking (Cbrs_align_any);
DockControlBar (&m_wndtoolbar);
Get a menu handle for a window
CMenu *pmenu = GetMenu ();
if (Null!=pmenu)
{
Delallmenu (Pmenu->getsafehmenu ());
}
return 0;
}