VS2013MFC the process of adding a menu bar to a dialog box, I have roughly divided these five steps.
First, add the menu to the resource View
In the resource view in workspace, on any of the folder icons , right-click the Insert (insert ) option and select menu in the popup dialog box , Click again , the New button , the menu will be added successfully , but it has not been completed, and can not be compiled , because the current menu space-time , at compile time will be erased.
Second, use the Menu editor to add menu bar and item
After the menu has been added successfully, the menu editor opens automatically, where you can add menu bars and menu items, which is relatively simple.
Three, load the menu into your dialog box
The first step is to add a menu item , which is actually added to your project , and then how to load the menu into your dialog box.
Open your newly added menu item and click "Project"--"Add Existing Item" here to select the existing class, which is the class of the dialog box for which you want to add a menu, for example,***dlg.cpp. And then determine.
Iv. adding code to the corresponding file
Open the dialog header file ***dlg.h, declaring the CMenu variable , such as M_menu;
Open the ***dlg.cpp file and add the following statement in ***dlg::oninitdlg ():
M_menu.loadmenu (IDR_MENU1); Idr_menu1 the ID of the menu you added , you can find it in the Menus folder of the resource view.
SetMenu (&m_menu);
This will be OK, debugging, the menu will already appear in the corresponding dialog box.
Use the wizard to generate a menu message response function
Select the Class Wizard under Project, select the class name***dlg.cpp, and in Object ID (B) Under the Commands tab, select the corresponding ID for each submenu item, and then double-click the command message in message (S) .
The dialog box will pop up and you can change the function name of the corresponding submenu item and click OK. The menu message response function is generated, adding the code you need.
To add a menu bar (CMenu) based on the MFC dialog box program