Microsoft KB Archive/143290

= PRB: Setting Menu Items to Grayed Does Not Disable the Item =

Article ID: 143290

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 2.2

 Microsoft Visual C++ 4.0 Standard Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul>

 Microsoft Visual C++ 4.2 Enterprise Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul>

<ul> <li>Microsoft Visual C++ 1.0 Professional Edition</li></ul>

<ul> <li>Microsoft Visual C++ 1.5 Professional Edition</li></ul>

<ul> <li>Microsoft Visual C++ 1.51</li></ul>

<ul> <li>Microsoft Visual C++ 1.52 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q143290

<div class="symptoms_section">

SYMPTOMS
If you create a popup menu item and select its Grayed property in AppStudio, the menu item will appear Grayed in AppStudio and the GRAYED attribute will appear in the .RC file, but the menu item may not appear Grayed (disabled) when you run the application. The same behavior may appear for menus with the Inactive property.

<div class="cause_section">

CAUSE
CFrameWnd has a member variable name m_bAutoMenuEnabled, which is described in the Class Library reference. The documentation states that this variable is set to TRUE by default, meaning that any menu item that has an ON_COMMAND handler but no corresponding ON_UPDATE_COMMAND_UI handler will be automatically enabled. This variable overrides any setting you may have selected in your resource file.

<div class="resolution_section">

RESOLUTION
If you would like to change this behavior, either implement the ON_UPDATE_COMMAND_UI handler or set the value of m_bAutoMenuEnabled to FALSE in the derived CFrameWnd constructor.

<div class="status_section">

STATUS
This behavior is by design.

<div class="references_section">