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

    How do I Enable/Disable Menu Items on a MDI

    I am having trouble getting the EnableMenuItem function to work properly in either a SDI or MDI application. Basically, I am doing a


    GetMenu()->EnableMenuItem( ID_MENU_ITEM, MF_GRAYED )




    This works fine in a dialog project, but in a SDI or MDI project, it does not work at all. The functions seem to execute properly, but the menu items do not gray out. Its certainly possible I could just not be placing it in the right place, but I have tried everywhere I can think of. Any help would be appreciated. Please email me at [email protected].


  2. #2
    Guest

    Re: How do I Enable/Disable Menu Items on a MDI

    Ok, I just found a way to make it work. All I had to do was set the m_bAutoMenuEnable member variable of the CFrameWnd object to false. This made the


    GetMenu()->EnableMenuItem( ID_MENU_ITEM, MF_GRAYED );




    work properly. If there are other methods please let me know.

    Thanks.


  3. #3
    Join Date
    Jun 1999
    Location
    Toulouse - France
    Posts
    135

    Re: How do I Enable/Disable Menu Items on a MDI

    You can add an update message to your menu item with ClassWizard
    And the update function is like:
    [ccode]
    void CDialog::OnUpdateMenuItem(CCmdUI* pCmdUI)
    {
    if ( condition )
    pCmdUI->Enable(TRUE); // Condition TRUE, the menu item is enable
    else
    pCmdUI->Enable(FALSE); // else, it is disabled

    }

    HTH

    Sandrine


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