From: bmelt on
I use GetContextMenuManager()->ShowPopupMenu and I need one item to be
disabled in some cases.
Following code does not work for me:
CMFCPopupMenu* pMenuActive = CMFCPopupMenu::GetActiveMenu();
CMFCToolBarMenuButton* pMenuButton = pMenuActive->GetMenuItem(0);
pMenuButton->EnableWindow(FALSE);
Attempt to use EnableMenuItem also did not help.

Could you please advise how to display CMFCPopupMenu with an item disabled
conditionally?

Thanks,
-Boris
From: AliR on
Have you trid ON_UPDATE_COMMAND_UI

In your window's message map:
ON_UPDATE_COMMAND_UI(ID_OF_MENUITEM,OnUpdateMenuItem)


void CMyWndClass::OnUpdateMenuItem(CCmdUI *pCmdUI)
{
pCmdUI->Enable(BasedOnYourCondition);
}

AliR.


"bmelt" <bmelt12345(a)community.nospam> wrote in message
news:B0D5052A-40E7-4801-B4ED-38E82A89CCEF(a)microsoft.com...
>I use GetContextMenuManager()->ShowPopupMenu and I need one item to be
> disabled in some cases.
> Following code does not work for me:
> CMFCPopupMenu* pMenuActive = CMFCPopupMenu::GetActiveMenu();
> CMFCToolBarMenuButton* pMenuButton = pMenuActive->GetMenuItem(0);
> pMenuButton->EnableWindow(FALSE);
> Attempt to use EnableMenuItem also did not help.
>
> Could you please advise how to display CMFCPopupMenu with an item disabled
> conditionally?
>
> Thanks,
> -Boris


From: DanB on
bmelt wrote:
> I use GetContextMenuManager()->ShowPopupMenu and I need one item to be
> disabled in some cases.
> Following code does not work for me:
> CMFCPopupMenu* pMenuActive = CMFCPopupMenu::GetActiveMenu();
> CMFCToolBarMenuButton* pMenuButton = pMenuActive->GetMenuItem(0);
> pMenuButton->EnableWindow(FALSE);
> Attempt to use EnableMenuItem also did not help.
>
> Could you please advise how to display CMFCPopupMenu with an item disabled
> conditionally?
>

It sounds like you are using a menu that is mapped to command handlers.
The handler takes precedence so use a ON_UPDATE_COMMAND_UI(...) to
disable the item.

Best, Dan.
From: Rong-Chun Zhang [MSFT] on
Hello Boris,

I agree with AliR, please try the suggestion. Also the managed support
service of the newsgroup microsoft.public.vc.mfc is now available instead
on Visual C++ General forum:
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/. Would you please
repost the question in the forum with the Windows Live ID used to access
your Subscription benefits? Our engineers will assist you in the new
platform. The article
http://msdn.microsoft.com/en-us/subscriptions/aa974230.aspx introduces more
information about the migration. In the future, please post your
MFC-related questions directly to the forums. If you have any questions or
concerns, please feel free to contact us: msdnmg(a)microsoft.com.

Regards,
Rongchun Zhang
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg(a)microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

MSDN Managed Newsgroup and Forum support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

From: jionmircea on
if ( hHenu!=NULL )
{
CMFCPopupMenu *ppopupMenu;
ppopupMenu = new CMFCPopupMenu;
ppopupMenu->Create(this, point.x, point.y, hMenu, FALSE, TRUE);
ppopupMenu->RecalcLayout();

CMFCToolBarMenuButton *pmenuButton;
pmenuButton = ppopupMenu->GetMenuItem(0);
pmenuButton->m_nStyle |= TBBS_DISABLED;

ppopupMenu->ShowWindow(SW_SHOWNA);

}