Menu items possess attributes that affect their appearance. For example, a menu item can be checked or unchecked, mutually exclusive, or dimmed. You can change other menu attributes as well by creating an owner-drawn menu item. Each menu item in a command bar or menu has a unique position value. The leftmost item in a command bar or the top item in a menu has position zero. The position value is incremented for subsequent menu items. Windows CE assigns a position value to all menu items, including separators. When calling a menu function that modifies or retrieves information about a specific menu item, specify the item by using either its handle or its position.
A check mark attribute controls whether a menu item is checked. Applications check or uncheck a menu item to indicate whether an option is in effect. For example, suppose that an application has a toolbar that a user can hide or display by using a Toolbar command on a menu. When the toolbar is hidden, the Toolbar menu item is unchecked. When the user chooses the command, the application checks the menu item and shows the toolbar. Windows CE displays a bitmap next to checked menu items to indicate their checked state; it does not display a bitmap next to unchecked items. Only menu items in a menu can be checked. Items appearing in a command bar cannot be checked. To set a menu item check mark attribute, call the CheckMenuItem function.
Sometimes, a group of menu items corresponds to a set of mutually exclusive options. In this case, indicate the selected option by using a checked radio menu item—analogous to a radio button control. Checked radio items are displayed with a bullet bitmap instead of a check mark bitmap. To check a menu item and make it a radio item, use the CheckMenuRadioItem function.
Another menu item attribute you can change is whether or not a menu item is enabled. When a menu item is not available, the item should be dimmed. Dimmed menu items cannot be chosen. You can use a dimmed item when an action is not appropriate. For example, you can dim the Print command on the File menu when the system does not have a printer installed. A menu item can be enabled or dimmed by using the EnableMenuItem function. To determine whether a menu item is enabled or dimmed, use the GetMenuItemInfo function.
You can control a menu item's appearance by using an owner-drawn item. Owner-drawn items require an application to draw selected, checked, and unchecked states. For example, if an application provides a font menu, it can draw each menu item by using the corresponding font; the item for Roman will be drawn in Roman, the item for Italic will be drawn in Italic, and so on.
Windows CE handles owner-drawn menu items differently from Windows-based desktop platforms. In some respects, it treats an owner-drawn item as any other menu item. On other Windows-based platforms, the device context is initialized to its default state. On Windows CE, the device context is initialized to the dimmed or highlighted status of the current item. Also, unlike other Windows-based platforms, Windows CE automatically highlights an owner-drawn menu item when it has the keyboard focus.