Normally, when you check a menu item, Windows displays the standard Windows checkmark next to the item text. A menu item that is not checked has no special mark next to it at all.
However, you can specify a bitmap, instead of the standard Windows checkmark, to display when an item is checked. You can also specify a bitmap to display when a menu item is not checked.
Custom checkmarks can be particularly useful for helping the user distinguish between menu commands that perform an action and commands that can be checked but are not currently checked. Some Windows applications use the following conventions:
Type of Menu Item | Convention |
Menu items that perform an action (for example, display another menu or a dialog box) | Do not display a checkmark for such an item. |
Menu items that are currently checked | Display either a normal Windows checkmark or a custom checkmark. When the user chooses a checked item again, remove the checkmark. |
Menu items that can be checked but are not currently checked | Display a custom checkmark. When the user chooses an unchecked item, display either a standard Windows checkmark or a different custom checkmark. |
To provide your own checkmark bitmaps:
1.Use the Image Editor to create the bitmaps you want to use as checkmarks.
Windows requires that your checkmark bitmaps be the same size as the standard checkmarks. Although you can, during run time, stretch or shrink your checkmark bitmaps to the right size, it's a good idea to start with a bitmap that's close to the right size. (The size of the standard checkmarks depends on the current display device. To find out the current size of the standard checkmarks, use the GetMenuCheckMarkDimensions function.)
You can also create a bitmap “by hand” — by coding the individual bits. For an explanation, see “Creating a Bitmap with Hard-Coded Bits”.
2.In your application's resource script file, define each bitmap's name and source file using the BITMAP statement. For example:
BitmapChecked BITMAP CHECK.BMP
BitmapNotChecked BITMAP NOCHECK.BMP
3.In your application source code, use the LoadBitmap function to load each bitmap from your application resources.
4.Use the GetMenuCheckMarkDimensions function to find out the size of the standard checkmarks on the current display device.
5.If necessary, use the StretchBlt function to stretch or shrink each bitmap to the right size.
6.Use the SetMenuItemBitmaps function to specify the checkmark bitmaps for each menu item.
7.Before your application terminates, it should destroy the bitmaps to free memory.
The following example shows how to specify checkmark bitmaps for a
menu item:
SetMenuItemBitmaps (hMenu, /* handle to menu */
0, /* position of menu item */
MF_BYPOSITION,
hbmCheckOff, /* bitmap for unchecked item */
hbmCheckOn); /* bitmap for checked item */