Microsoft KB Archive/86774

= Microsoft Knowledge Base =

WMenuEnabled May Return True for Grayed Menu Item
Last reviewed: October 19, 1994

Article ID: Q86774

The information in this article applies to:

- Microsoft Test for Windows, versions 1.0 and 2.0

SUMMARY
The TestBasic functions WMenuEnabled and WMenuEnabledX may return True for menu items that are inactive. Menu items have independent status information that state whether they are enabled and whether they are grayed. This means that a menu item can be &quot;grayed out&quot; and simultaneously be enabled.

The FastTest functions BMenuItemEnabled, XMenuItemEnabled, and XMenuItemNotEnabled may produce similar unexpected results for menu items that are grayed because they use the WMenuEnabled function.

Because most Windows applications do not explicitly disable their menus but simply gray the menu items, you should generally use the WMenuGrayed and WMenuGrayedX functions instead to determine whether a menu item is active.

This information applies to Microsoft Test for Windows version 1.0.

MORE INFORMATION
The following test script demonstrates that the Window version 3.1 Write application contains inactive menu items that are grayed but enabled.

 Start Test Driver.  In a new test script, type the following code: REM $DEFINE W_MENU REM $INCLUDE: 'MSTEST.INC' RUN &quot;WRITE.EXE&quot;, NOWAIT WMenu &quot;Edit&quot; IF WMenuEnabled(&quot;Cut&quot;) THEN PAUSE &quot;Enabled&quot; ELSE PAUSE &quot;Disabled&quot; END IF WMenu &quot;Edit&quot; IF WMenuGrayed(&quot;Cut&quot;) THEN PAUSE &quot;Grayed&quot; ELSE PAUSE &quot;Not Grayed&quot; END IF  Press F5 to run the script.

The script displays &quot;Enabled&quot;, then &quot;Grayed&quot;.