Disable menu item in popup menu 
Author Message
 Disable menu item in popup menu

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);

Quote:
}

I also tried
 pSubMenu->EnableMenuItem(ID_MENUITEMID , MF_DISABLED|MF_BYCOMMAND);
but also in vain

any idea???

thanks in advance
M.Badr



Mon, 03 Mar 2003 03:00:00 GMT  
 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


Mon, 03 Mar 2003 03:00:00 GMT  
 Disable menu item in popup menu
I think you should be using

    pSubMenu = c-ParentMenu.GetSubItem (0);

and

    pSubMenu -> EnableMenuItem ( ID_MENUITEMID, MF_GRAYED | MF_BYCOMMAND );


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.

- Show quoted text -

Quote:
> 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



Tue, 04 Mar 2003 05:11:07 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to disable/enable Popup menu item of the main menu

2. disable popup menu item

3. enable, disable popup menu items

4. Disabling items in popup menus

5. Promlem with popup menu items disabled

6. How to enable/disable popup menu items

7. How to disable popup menu items

8. Disable item in Popup Menu?

9. dynamically disable popup menu items

10. Access keys for menu items in popup menus

11. Problem with owner-draw menus and items with popup-menu

12. Enabling/Disabling Menu items for a menu on a dialog application

 

 
Powered by phpBB® Forum Software