How to add a menu in the VS2010 VC + + dialog-based MFC program

Source: Internet
Author: User

Method 1: Pro-Test successfully reproduced from Https://social.msdn.microsoft.com/Forums/vstudio/zh-CN/48338f6b-e5d9-4c0c-8b17-05ca3ef1f761/vs2010dialog

You can create a menu as a resource and then attach it to a dialog box. Open the dialog" Properties" dialog box, you can see a menu property, and in the end we will specify an ID for our own creation.

The steps are as follows:


• in the resource view, right-click the project name and insert a new menu. This menu will have an ID(for example: idr_menu1 );

• the menu can be designed to suit your needs.

• After designing the menu, in the Dialog menu property drop- down list, select the desired menu ID(here idr_menu1)

Now that the compilation is running, the menu can be displayed in the dialog box.

Method 2: Reproduced not tried

Add menu in VC + + dialog box program

Create a dialog-based MFC program in VC with a total of three steps to add the menu:

1, first insert a menu resource idr_menu1, and then you can edit the Modify menu;

2. Then add a member variable M_menu for the CMenu type for the dialog box;

3. Add the following code in OnInitDialog ():

M_menu.loadmenu (idr_menu1);//Load Menu
SetMenu (&m_menu); Show Menu

After these three steps, the menu can be displayed.

How to add a menu in the VS2010 VC + + dialog-based MFC program

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.