Reputation: 217
I would like to add sub options to the Main Menu at the top of a main frame window in MFC.
For example; File>Open, or Edit>Undo.
Is this possible to do at all? My intention is to replace the function of some buttons in my program with options typically found in the drop down menus
Also after adding an item to the Main Menu how would you use it to call a function?
Upvotes: 0
Views: 2194
Reputation: 19197
Here I have added an entry to the View menu called Test:
When I build and runt he program it shows disabled:
This is because I still have to create an event handler. In the resource editor you right-click the menu item and select Add Event handler:
This brings up the class wizard:
On the dialogue there are a couple of menu event handlers to choose from. Select the one you need (as in the screen shot) but don't forget to choose the right class on the right. Then click Add and Edit.
Now you can add your event handler functionality. Example:
void CMainFrame::OnViewTest()
{
AfxMessageBox(_T("Hello!"), MB_OK | MB_ICONINFORMATION);
}
When I compile and run this:
Hopefully this will help you get up and running.
Upvotes: 1