Help Center

SetItemBitmapsfunction

Associates the specified bitmap with a 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 SetItemBitmaps (BYVAL hMenu AS HMENU, BYVAL item AS LONG, BYVAL hBitmapUnchecked AS HBITMAP, BYVAL hBitmapChecked AS HBITMAP, BYVAL fByPosition AS BOOLEAN = FALSE) AS BOOLEAN

Parameters

NameDescription
hMenuA handle to the menu containing the item to receive new check-mark bitmaps.
itemThe identifier or position of the menu item to be changed. The meaning of this parameter depends on the value of fByPosition.
hBitmapUncheckedA handle to the bitmap displayed when the menu item is not selected.
hBitmapCheckedA handle to the bitmap displayed when the menu item is selected.
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

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.

Description

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.

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.

Example

CMenu.CheckItem(hMenu, IDM_OPEN) CMenu.SetItemBitmaps(hMenu, IDM_OPEN, NULL, NULL)

Reference

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