Hi there,
I'm trying to manage my own recent files list as part of my File drop down menu.
In my .rc file I have:
IDR_MAINFRAME MENU BEGIN POPUP "&File" BEGIN MENUITEM "&New", ID_FILE_NEW MENUITEM "&Open", ID_FILE_OPEN MENUITEM "Recent File", ID_RECENT_FILE MENUITEM "&Exit", ID_FILE_EXIT END END
Then in my callback for ID_RECENT_FILE I have:
CXTPCommandBar* menuBar = MainFrame::GetInstance()->m_menuBar; if (menuBar) { CXTPControls* pControls = menuBar->GetControls(); CXTPControl* pControl = pControls->GetAt(0); // File menu is 0 CXTPControls* pUtilCtrls = pControl->GetCommandBar()->GetControls(); CXTPControl* pSubMenuItemCtrl = pUtilCtrls->GetAt(2); // New (0), Open (1), Recent File (2) CMenu *SubMenu = new CMenu; SubMenu->CreatePopupMenu();
SubMenu->AppendMenu(MF_BYPOSITION | MF_STRING, kBaseEffectMenuOptionId2+1, _T("Item3-1")); SubMenu->AppendMenu(MF_BYPOSITION | MF_STRING, kBaseEffectMenuOptionId2+2, _T("Item3-2")); SubMenu->AppendMenu(MF_BYPOSITION | MF_STRING, kBaseEffectMenuOptionId2+3, _T("Item3-3")); CMenu *SubSubMenu = new CMenu; SubSubMenu->CreatePopupMenu(); SubSubMenu->InsertMenu(0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)SubMenu->m_hMenu, _T("Recent File"));
pUtilCtrls->AddMenuItem(SubSubMenu, 0); }
The problem is that the AddMenuItem() seems to just put the new menu at the bottom of my File menu. So I get:
New Open Recent File Exit Recent File
How do I move it (and replace) the existing "Recent File" entry that appears 3rd in the list?
Many thanks
|