CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: EnableMenuItem

  1. #1
    Join Date
    Jun 2001
    Posts
    25

    EnableMenuItem

    I've got another problem thats got me stumped.

    I've got a dialog app with a popup menu in the system tray. I want to disable items in the menu but every method I've tried doesn't work.

    This is what I've tried last and it doesn't work.

    CMenu m_Menu, *pSubMenu;
    m_Menu.LoadMenu(IDR_POPUP_MENU);
    pSubMenu = m_Menu.GetSubMenu(0);
    pSubMenu->EnableMenuItem(ID_POPUP_ABOUT, MF_BYCOMMAND | MF_GRAYED);

    Thanks.
    Dan.


  2. #2
    Join Date
    Jun 2001
    Location
    Lewes, UK
    Posts
    1,313

    Re: EnableMenuItem

    you need to override CWnd::OnInitMenuPopup

    Hope this helps

    Eugene Gill

    Please take the time to rate this answer if you found it useful. It will make me a happy man!

  3. #3
    Join Date
    Jun 2001
    Posts
    25

    Re: EnableMenuItem

    I had a quick look but couldn't find it. Is it available to a dialog app? My app doesn't have a main frame.

    Thanks.
    Dan.


  4. #4
    Join Date
    Jun 2001
    Location
    Lewes, UK
    Posts
    1,313

    Re: EnableMenuItem

    Add a handler for WM_INITMENUPOPUP in you dialog. To do this through class wizard you will need to go to the class info tab and change the message filter from Dialog to Window.

    Hope this helps

    Eugene Gill

    Please take the time to rate this answer if you found it useful. It will make me a happy man!

  5. #5
    Join Date
    Jun 2001
    Posts
    25

    Re: EnableMenuItem

    I gave that a go but it still doesn't work.

    I used the info on this page http://www.codeguru.com/mfc/comments/16665.shtml

    I'm sure I'm doing something wrong.

    Dan.


  6. #6
    Join Date
    Jun 2001
    Location
    Lewes, UK
    Posts
    1,313

    Re: EnableMenuItem

    I'd like to help but I have to go out now. Post your code for WM_INITMENUPOPUP for others to see.


    Hope this helps

    Eugene Gill

    Please take the time to rate this answer if you found it useful. It will make me a happy man!

  7. #7
    Join Date
    Jun 2001
    Posts
    25

    Re: EnableMenuItem

    The code I used is on this page:

    http://www.codeguru.com/mfc/comments/16665.shtml

    Thanks.
    Dan.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured