Help Center

SetMenuItemStatefunction

Windowsfunctiondoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Syntax

FUNCTION SetMenuItemState (BYVAL hMenu AS HMENU, BYVAL uItem AS DWORD, BYVAL fState AS DWORD, BYVAL fByPosition AS LONG = FALSE) AS BOOLEAN
Also documented as SetItemState — one description covers them all.

Parameters

NameDescription
hMenuHandle to the menu that contains the menu item.
uItemThe identifier or position of the menu item to get information about. The meaning of this parameter depends on the value of fByPosition.
fStateThe menu item state. It can be one or more of these values:
MFS_CHECKED: Checks the menu item.
MFS_DEFAULT: Specifies that the menu item is the default.
MFS_DISABLED: Disables the menu item and grays it so that it cannot be selected.
MFS_ENABLED: Enables the menu item so that it can be selected. This is the default state.
MFS_GRAYED: Disables the menu item and grays it so that it cannot be selected.
MFS_HILITE: Highlights the menu item.
MFS_UNCHECKED: Unchecks the menu item.
MFS_UNHILITE: Removes the highlight from the menu item. This is the default state.
fByPositionThe meaning of uItem. If this parameter is FALSE, uItem is a menu item identifier. Otherwise, it is a menu item position.

Return value

TRUE or FALSE. To get extended error information, use the GetLastError function.

Description

Sets the state of the specified menu item.

Remarks

The application must call the CMenu.DrawBar function whenever a menu changes, whether or not the menu is in a displayed window. SetItemState does this call internlly.

Example

CMenu.SetItemState(hMenu, IDM_OPEN, MFS_CHECKED)

Reference

  • Documented in Windows/WIndows Controls/CMenu Class.md
  • Topic: About Menus