I think you misunderstood the question.
submenu in a menu. He didn't say anything about disabling or enabling the
popup menu.
You can do this in your OnContextMenu() handler by using an "index" to
disable the item. It also makes it impossible to get to the sub menu
since it will not longer popup.
Something like:
bool bEnable = (SomeCriteria);
CMenu menu;
VERIFY(menu.LoadMenu(IDR_RIGHTCLICK));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
// Dim out popup item if we can't do it here
UINT fGray = bEnable ? 0 : MF_GRAYED;
pPopup->EnableMenuItem(2, MF_BYPOSITION|fGray); // Popup is index 2 (3rd
item from top) on the menu
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
this);
I think it looks better to leave it in there dimmed out since that
indicates that the function exists, it just isn't valid for a particular
case.
Tom
"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message
news:LTYFh.5501$BE2.1000@newssvr27.news.prodigy.net...
I don't think that windows send messages for popup menus (since they don't
have ids)
Why would you want to do that?
Are you trying to set the PopupItem1 and PopupItem2 dynamically.
If so the only way I can think of to do this is to either add the submenu
(using InsertMenu) and remove it (using RemoveMenu).
Or insert and delete menu items from the popup menu using InsertMenuItem
and DeleteMenu.
AliR.