Help Center

SetStatefunction

Sets the state of the specified menu item.

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 SetState (BYVAL hMenu AS HMENU, BYVAL item AS LONG, BYVAL fState AS UINT, BYVAL fByPosition AS BOOLEAN = FALSE) AS BOOLEAN

Parameters

NameDescription
hMenuA handle to the menu that contains the menu item.
item
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 item. If this parameter is FALSE, item is a menu item identifier. Otherwise, it is a menu item position, where position = 1 for the first position, position = 2 for the second, and so on.

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. SetState does this call internally.

Example

CMenu.SetState(hMenu, IDM_OPEN, MFS_CHECKED)

Reference

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