CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    How can Enable and Disable menu item?

    Hi all,

    How can Enable and Disable Menu item in SDI type application of MFC-VC++2005.There is Enable and disable propery is present in Menu Properties but i dont want to use it because it is manully enable and disable menu item.

    i want to enable and disable requried menu item with using of function.

    Please help me for this how can i do this.

    Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    111

    Re: How can Enable and Disable menu item?


  3. #3
    Join Date
    Feb 2005
    Posts
    2,160

    Re: How can Enable and Disable menu item?

    Since it's SDI, the preferred way of doing this is with the ON_COMMAND and ON_UPDATE_COMMAND_UI macros.

    Look in the MESSAGE_MAP of your view. You should see some common handlers already:

    Code:
    BEGIN_MESSAGE_MAP(CMyView, CScrollView)
      //...
      ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
      ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
    END_MESSAGE_MAP()
    See:
    http://msdn.microsoft.com/en-us/libr...b7(VS.80).aspx

  4. #4
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: How can Enable and Disable menu item?

    And if you are not using MFC, take a look at WM_INITPOPUPMENU to get the menu just before it is shown, then use EnableMenuItem() to Enable or Disable it.


    -Erik

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