There are four general create MFC program types, namely a single document, multiple documents, based on dialog and top-level document. Which is only based on the type of dialog box does not own menu bar, if desired, can also be created manually, it is very simple.
How to add a menu?
Here to VS2012 example.
You must first create a menu
right in the resource view, select Add Resource
selection menu resources, and then create, if there is a ready resource can be imported.
Edited menu, and save.
Next to display the menu on the dialog box
to look at what the menu ID is to know which menu you want to add. (ID menu is best to change it, just for easy identification)
found in the Menu Item Properties dialog box interface, select this menu. Note that not SystemMenu.
Compile and run! ! Program has a menu.
Add a menu in code
First create a menu, as with the above method
and then create a CMenu types of variables in the header file, called m_menu
CMenu m_menu;
Then add in the initialization function cpp file:
// 加载菜单资源
m_menu.LoadMenu(IDR_MENU1);
// 设置菜单
this->SetMenu(&m_menu);
The same effect.
Add a message response function to a menu
After receiving the setup menu click message, the response function is made.
Right-click options to set, click Add a message event handler
to set various properties
when received will be called when clicked. It recommended that you create before to modify ID option, if not modify the default digital, easy to distinguish and identify.