Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

SetMenuItemBitmaps function

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 WINAPI SetMenuItemBitmaps(
  _In_      HMENU hMenu,
  _In_      UINT uPosition,
  _In_      UINT uFlags,
  _In_opt_  HBITMAP hBitmapUnchecked,
  _In_opt_  HBITMAP hBitmapChecked
);

Parameters

hMenu [in]

Type: HMENU

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

uPosition [in]

Type: UINT

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

uFlags [in]

Type: UINT

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

ValueMeaning
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.

 

hBitmapUnchecked [in, optional]

Type: HBITMAP

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

hBitmapChecked [in, optional]

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 CXMENUCHECK and CYMENUCHECK values to retrieve the bitmap dimensions.

Examples

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

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Menus

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.