In my menu, the default menu items under FILE are:
File Edit View
-> New
-> Open
...etc...
I want to programmatically/dynamically add a pop menu as a menu item under File:
File
-> New
-> MyPopupMenu
-> Open
where the menu items under MyPopupMenu are:
-> MyPopupMenu
-> Item 0
-> Item 1
-> Item 2
Regardless of what I do, MyPopupMenu is always incorrectly inserted to the right of FILE. That is, my menu appears as follows:
File MyPopupMenu Edit View
The code below illustrates how I am attempting to add MyPopupMenu. How do I modify the code so that MyPopUpMenu appears as a menu item under FILE instead of to the right of FILE in the menu?
Thanks in advance
Ian
// sample code called at the end of CMainFrame::LoadFrame()
CMenu* menu = GetMenu();
ASSERT( NULL != menu && ::IsMenu( *menu ) );
CMenu popupMenu;
VERIFY( popupMenu.CreatePopupMenu() );
UINT startID = 38040;
VERIFY( popupMenu.AppendMenu( MF_STRING, startID + 0, _T("Item #0") ) );
VERIFY( popupMenu.AppendMenu( MF_STRING, startID + 1, _T("Item #1") ) );
VERIFY( popupMenu.AppendMenu( MF_STRING, startID + 2, _T("Item #2") ) );
MENUITEMINFO info = { 0 };
info.cbSize = sizeof( MENUITEMINFO );
info.fMask = MIIM_SUBMENU | MIIM_STRING;
info.hSubMenu = popupMenu.Detach();
info.dwTypeData = _T("MyPopupSubMenu") ;
VERIFY( menu->InsertMenuItem( 1, &info, TRUE ) );