Asp.net two ways to delete the default menu bar of a single MFC Document

Source: Internet
Author: User

There are two methods:

Method 1: Reload the create function of the framework class.CodeAs follows:Copy codeThe Code is as follows: bool cmainframe: Create (maid, maid, DWORD dwstyle, const rect & rect, cwnd * pparentwnd, maid, DWORD dwexstyle, ccreatecontext * pcontext)
{
// Todo: Add dedicated code and/or call the base class here
// Return cframewnd: Create (lpszclassname, lpszwindowname, dwstyle, rect, /// pparentwnd, lpszmenuname, dwexstyle, pcontext );
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 );
}

Method 2: manually delete all menu items. Specifically, define a function to delete all menu items:Copy codeThe Code is as follows :/*!
* \ Brief deletes all Menu Bars.
*
* Delete All Menu Bars in the window.
* \ Return none.
*/
Static void delallmenu (hmenu)
{
// Delete unnecessary menu items first
Int menucount = getmenuitemcount (hmenu );
For (INT I = Menucount-1; I>-1; I --)
{
: Deletemenu (hmenu, I, mf_byposition );
}
}

Then, call this function in the oncreate function of the framework class as follows:Copy codeThe Code is as follows: int cmainframe: oncreate (maid)
{
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)
{< br> trace0 ("Toolbar \ n not created");
return-1; // failed to create
}< br> If (! M_wndstatusbar.create (this) |
! M_wndstatusbar.setindicators (indicators,
sizeof (indicators)/sizeof (uint)
{< br> trace0 ("unable to create status bar \ n ");
return-1; // creation failed
}< br> // todo: You can dock a toolbar if you do not need it, delete the three rows
m_wndtoolbar.enabledocking (cbrs_align_any);
enabledocking (cbrs_align_any);
dockcontrolbar (& m_wndtoolbar );
// obtain the menu handle of the window
cmenu * pmenu = getmenu ();
If (null! = Pmenu)
{< br> delallmenu (pmenu-> getsafehmenu ();
}< br> return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.