none
Setting checks of context menu items RRS feed

  • Question

  • I am making a  popup menu resource in my MFC project.
    I can call it in OnRButtonDown event with code below :

     CMenu menuPop;

     menuPop.LoadMenu(IDR_MENU_MAIN);
     POINT ptMouse;
     GetCursorPos(&ptMouse);
     menuPop.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,    ptMouse.x,ptMouse.y,this);

    All i want to do is to change check of items. Its first menu items is checked by default.
    I tried code below to make first menu item  unchecked but it didnt work :

     CMenu menuPop;
     menuPop.LoadMenu(IDR_MENU_MAIN);
     menuPop.CheckMenuItem(0,MF_BYPOSITION  | MF_UNCHECKED);

    How can i set check states of menu items in my popup style -context menu ?

    Friday, June 29, 2007 9:36 AM

Answers

  •  akhin wrote:

    [...]

    All i want to do is to change check of items. Its first menu items is checked by default.
    I tried code below to make first menu item  unchecked but it didnt work :

     CMenu menuPop;
     menuPop.LoadMenu(IDR_MENU_MAIN);
     menuPop.CheckMenuItem(0,MF_BYPOSITION  | MF_UNCHECKED);

    How can i set check states of menu items in my popup style -context menu ?

     

    I think you should also try this:

     

    menuPop.GetSubMenu(0).CheckMenuItem(0, MF_BYPOSITION  | MF_UNCHECKED);

     

     

    Friday, June 29, 2007 9:41 AM