SetItemBitmapsfunction
Associates the specified bitmap with a menu item.
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
| Name | Description | |
|---|---|---|
hMenu | A handle to the menu containing the item to receive new check-mark bitmaps. | |
item | The identifier or position of the menu item to be changed. The meaning of this parameter depends on the value of fByPosition. | |
hBitmapUnchecked | A handle to the bitmap displayed when the menu item is not selected. | |
hBitmapChecked | A handle to the bitmap displayed when the menu item is selected. | |
fByPosition | The 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