
Disable menu item in popup menu
Be aware that
MFC command routing is still handling enable/disable
messages even for popup menus, so if you have a handler for that menu
ID, your ON_COMMAND_UI handler will be called, and override anything
else you have done.
joe
On Thu, 14 Sep 2000 11:34:43 -0700, "Mohamed Badr"
Quote:
>Hi all,
>I'm creating a popup menu and I wanna Disable a given menu item in it
>I tried this code but it only shows the menu and it doesn't disable the menu
>item
>void CTmpView::OnRButtonUp(UINT nFlags, CPoint point)
>{
> CMenu cParentMenu;
> cParentMenu.LoadMenu(IDR_MENU1);
> CMenu *pSubMenu = cParentMenu.GetSubMenu(1);
> ClientToScreen(&point);
> pSubMenu->EnableMenuItem(1,MF_DISABLED|MF_BYPOSITION);
>pSubMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,point.
>x,point.y,this);
> cParentMenu.DestroyMenu();
> CView::OnRButtonUp(nFlags, point);
>}
>I also tried
> pSubMenu->EnableMenuItem(ID_MENUITEMID , MF_DISABLED|MF_BYCOMMAND);
>but also in vain
>any idea???
>thanks in advance
>M.Badr
Joseph M. Newcomer [MVP]
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm