David Ching a 9crit :
"Jean-Fabrice RABAUTE" <jfr@core-services.fr> wrote in message
news:47a04111$0$29542$426a74cc@news.free.fr...
Hi,
Using an Office 2007 style based on the new MFC Feature Pack, I am
trying to customize a popup menu displayed on a toolbar button.
I am using CMainFrame::OnShowPopupMenu for this, but there is no change
at all on the menu.
Are you talking about a dropdown menu that appears below a ribbon button
when it is clicked? For these, you would probably (I'm not sure)
customize the menu using ribbon API.
-- David
Hi David,
Yes, the dropdown menu below a ribbon button.
I tried to use ribbon API without success.
I found this solution so far :
derive CMFCRibbonButton (for instance "CMyMFCRibbonButton").
Override "OnShowPopupMenu".
copye/paste the default code from "CMFCRibbonButton::OnShowPopupMenu", and
before the :
if (m_arSubItems.GetSize() > 0)
{
I use
RemoveAllSubItems();
AddSubItem(new CMFCRibbonButton(....
to change the menu dynamically.
I can test which button is firing the menu by using "GetID()" to get the
menu id.
Maybe there are other solution, but this one is working so far.
The problem with the default implementation is that
CMainFrame::OnShowMenuPopup is called AFTER the menu is created, so
adding/removing items has no effect.
It looks like it s a "ribbon" stuff, becuase using toolbar objects, the
CMainFrame::OnShowMenuPopup is working fine on menu customization.
Wow, that's complex! :-) But at least it works. Check out the ribbon
Maybe these samples will show how to do it easier. When I learned the
ribbon sample and modify it.