SetMenuItemBitmaps function (winuser.h)

Associates the specified bitmap with a menu item. Whether the menu item is selected or clear, the system displays the appropriate bitmap next to the menu item.

Syntax

BOOL SetMenuItemBitmaps(
  [in]           HMENU   hMenu,
  [in]           UINT    uPosition,
  [in]           UINT    uFlags,
  [in, optional] HBITMAP hBitmapUnchecked,
  [in, optional] HBITMAP hBitmapChecked
);

Parameters

[in] hMenu

Type: HMENU

A handle to the menu containing the item to receive new check-mark bitmaps.

[in] uPosition

Type: UINT

The menu item to be changed, as determined by the uFlags parameter.

[in] uFlags

Type: UINT

Specifies how the uPosition parameter is to be interpreted. The uFlags parameter must be one of the following values.

Value Meaning
MF_BYCOMMAND
0x00000000L
Indicates that uPosition gives the identifier of the menu item. If neither MF_BYCOMMAND nor MF_BYPOSITION is specified, MF_BYCOMMAND is the default flag.
MF_BYPOSITION
0x00000400L
Indicates that uPosition gives the zero-based relative position of the menu item.

[in, optional] hBitmapUnchecked

Type: HBITMAP

A handle to the bitmap displayed when the menu item is not selected.

[in, optional] hBitmapChecked

Type: HBITMAP

A handle to the bitmap displayed when the menu item is selected.

Return value

Type: BOOL

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

If either the hBitmapUnchecked or hBitmapChecked parameter is NULL, the system displays nothing next to the menu item for the corresponding check state. If both parameters are NULL, the system displays the default check-mark bitmap when the item is selected, and removes the bitmap when the item is not selected.

When the menu is destroyed, these bitmaps are not destroyed; it is up to the application to destroy them.

The selected and clear bitmaps should be monochrome. The system uses the Boolean AND operator to combine bitmaps with the menu so that the white part becomes transparent and the black part becomes the menu-item color. If you use color bitmaps, the results may be undesirable.

Use the GetSystemMetrics function with the SM_CXMENUCHECK and SM_CYMENUCHECK values to retrieve the bitmap dimensions.

Examples

For an example, see Simulating Check Boxes in a Menu.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See also

Menus