-
November 12th, 2008, 12:21 PM
#1
Dynamic Popup Menus
I am trying to create a context menu that lists all the buttons for each toolbar using popup submenus... something like this...
File>
___New
___Open
___Save
Edit>
___Cut
___Copy
___Paste
etc...
I create a popup menu like this...
Code:
CMenu menu;
VERIFY(menu.LoadMenu(IDR_TOOLBAR_POPUP_MENU));
// pPopupMenu is the highest level of my context menu...
CMenu* pPopupMenu = menu.GetSubMenu(0);
if (pPopupMenu)
{
CString cstr;
m_wndFileToolBar.GetWindowText(cstr);
bool bSuccess = pPopupMenu->InsertMenu(0, MF_BYPOSITION | MF_ENABLED, MF_POPUP, cstr);
CMenu* pSubMenu1 = pPopupMenu->GetSubMenu(0);
///////////////// pSubMenu1 is NULL at this point ... What am I doing wrong???
}
I am trying to get a pointer to the newly created popup "submenu" so I can add menu items to it to represent each button from the toolbar...
-
November 12th, 2008, 04:14 PM
#2
Re: Dynamic Popup Menus
I figured it out...
Code:
CMenu menu;
VERIFY(menu.LoadMenu(IDR_TOOLBAR_POPUP_MENU));
// pPopupMenu is the highest level of my context menu...
CMenu* pPopupMenu = menu.GetSubMenu(0);
if (pPopupMenu)
{
// create the new popup menu
CMenu menuFile;
VERIFY(menuFile.CreatePopupMenu());
// add items to the new popup menu
menuFile.AppendMenu(MF_STRING, ID_TOOLBAR_BUTTON_BASE, (LPCTSTR)"New");
// ...etc...
// get the title of the new popup menu
CString cstr;
m_wndFileToolBar.GetWindowText(cstr);
// add the NEW popup menu to the higherlevel popup menu
pPopupMenu->AppendMenu(MF_POPUP, (UINT) menuFile.m_hMenu, cstr);
// display the menu
pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pMsg->pt.x, pMsg->pt.y, this);
}
-
November 13th, 2008, 03:49 AM
#3
-
November 13th, 2008, 10:47 AM
#4
Re: Dynamic Popup Menus
Thanks Victor! I am not sure how I go about marking the thread as Resolved...
-
November 13th, 2008, 11:02 AM
#5
Re: Dynamic Popup Menus
Victor Nijegorodov
-
November 13th, 2008, 02:43 PM
#6
Re: Dynamic Popup Menus
Unfortunately, the Thread Tools menu item only pulls down FOUR items...
There is no "Mark Thread Resolved" item in the pull-down
-
November 14th, 2008, 03:50 AM
#7
Re: Dynamic Popup Menus
Hmmm, it seems to be a bug in a "new" forum version after the last update
OK, I'll report it to the Admin.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|