Compartilhar via


EnableMenuItem (Windows CE 5.0)

Send Feedback

This function enables or disables (grays) the specified menu item.

BOOLEnableMenuItem(HMENUhMenu, UINTuIDEnableItem, UINTuEnable );

Parameters

  • hMenu
    [in] Handle to the menu.

  • uIDEnableItem
    [in] The menu item to be enabled, disabled, or grayed, as determined by the uEnable parameter. This parameter specifies an item in a menu bar, menu, or submenu.

  • uEnable
    [in] Constants that control the interpretation of the uIDEnableItem parameter and indicate whether the menu item is enabled, disabled, or grayed. This parameter must be a combination of at least two of the following:

    • MF_BYCOMMAND or MF_BYPOSITION
    • MF_ENABLED, MF_DISABLED, or MF_GRAYED

    For information about these constants, see Menus Constants.

Return Values

The return value specifies the previous state of the menu item (it is either MF_ENABLED or MF_GRAYED). 0xFFFFFFFF indicates that the menu item does not exist.

Remarks

An application must use the MF_BYPOSITION flag to specify the correct menu handle. If the menu handle to the menu bar is specified, the top-level menu item (an item in the menu bar) is affected. To set the state of an item in a drop-down menu or submenu by position, an application must specify the handle to the drop-down menu or submenu.

When an application specifies the MF_BYCOMMAND flag, the system checks all items that open submenus in the menu identified by the specified menu handle. Therefore, unless duplicate menu items are present, specifying the menu handle to the menu bar is sufficient.

The InsertMenu and SetMenuItemInfo functions can also set the state (enabled or grayed) of a menu item.

Menu items cannot be disabled without being grayed. To disable a menu item, use the MF_GRAYED flag.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winuser.h.
Link Library: Menu.lib.

See Also

CreateMenu | InsertMenu | Menus Functions | Menus Constants

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.