![]() |
Help with dynamic menu items |
Post Reply ![]() |
Author | |
thomasmfields ![]() Newbie ![]() Joined: 23 June 2021 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() Posted: 20 February 2025 at 8:13am |
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
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |