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

    Making a menu item inactive

    How can I with code make a menu Item inactive at any time????
    Thanks


  2. #2
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: Making a menu item inactive

    When a menu is about to be displayed by your application, your mainframe class will receive a WM_INITMENUPOPUP message.

    Override this function and you can then call EnableMenuItem(ID_OF_ITEM, MF_DISABLED) on the Cmenu* pointer given you. Note, I am quoting this from memory, so my details might not be exactly correct...

    HTH


    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  3. #3
    Join Date
    Apr 1999
    Posts
    43

    Re: Making a menu item inactive

    Here u go. Use the MF_GRAYED to disable, and the MF_ENABLED to enable it.


    HMENU thisMenu = GetMenu(hwnd);

    // This specifies the 3rd pop-up menu
    HMENU thisSubMenu = GetSubMenu(thisMenu,2);
    bool bReturn;

    // IDM_MENUITEM is the menu item to disable
    bReturn = EnableMenuItem(thisSubMenu, IDM_MENUITEM, MF_GRAYED);




    Hope this helps.

    Todd


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