The DRAWITEMSTRUCT structure provides information the owner needs to determine how to paint an owner-draw control. The owner of the owner-draw control receives a pointer to this structure as the lParam parameter of the WM_DRAWITEM message.
typedef struct tagDRAWITEMSTRUCT
{
WORD CtlType;
WORD CtlID;
WORD itemID;
WORD itemAction;
WORD itemState;
HWND hwndItem;
HDC hDC;
RECT rcItem;
DWORD itemData;
} DRAWITEMSTRUCT;
The DRAWITEMSTRUCT structure has the following fields:
Field | Description | ||
CtlType | Is the control type. The values for control types are as follows: | ||
Value | Meaning | ||
ODT_BUTTON | Owner-draw button. | ||
ODT_COMBOBOX | Owner-draw combo box. | ||
ODT_LISTBOX | Owner-draw list box. | ||
ODT_MENU | Owner-draw menu. | ||
CtlID | Is the control ID for a combo box, list box or button. This field is not used for a menu. | ||
itemID | Is the menu-item ID for a menu or the index of the item in a list box or combo box. For an empty list box or combo box, this field can be –1. This allows the application to draw only the focus rectangle at the coordinates specified by the rcItem field even though there are no items in the control. This indicates to the user whether the list box or combo box has input focus. The setting of the bits in the itemAction field determines whether the rectangle is to be drawn as though the list box or combo box has input focus. | ||
itemAction | Defines the drawing action required. This will be one or more of the following bits: | ||
Value | Description | ||
ODA_DRAWENTIRE | This bit is set when the entire control needs to be drawn. | ||
ODA_FOCUS | This bit is set when the control gains or loses input focus. The itemState field should be checked to determine whether the control has focus. | ||
ODA_SELECT | This bit is set when only the selection status has changed. The itemState field should be checked to determine the new selection state. | ||
itemState | Specifies the visual state of the item after the current drawing action takes place. That is, if a menu item is to be grayed, the state flag ODS_GRAYED will be set. The state flags are: | ||
Value | Description | ||
ODS_CHECKED | This bit is set if the menu item is to be checked. This bit is used only in a menu. | ||
ODS_DISABLED | This bit is set if the item is to be drawn as disabled. | ||
ODS_FOCUS | This bit is set if the item has input focus. | ||
ODS_GRAYED | This bit is set if the item is to be grayed. This bit is used only in a menu. | ||
ODS_SELECTED | This bit is set if the item's status is selected. | ||
hwndItem | For combo boxes, list boxes and buttons, this field specifies the window handle of the control; for menus, it contains the handle of the menu (HMENU) containing the item. | ||
hDC | Identifies a device context; this device context must be used when performing drawing operations on the control. | ||
rcItem | Is a rectangle in the device context specified by the hDC field that defines the boundaries of the control to be drawn. Windows automatically clips anything the owner draws in the device context for combo boxes, list boxes, and buttons, but does not clip menu items. When drawing menu items, the owner must ensure that the owner does not draw outside the boundaries of the rectangle defined by the rcItem field. | ||
itemData | For a combo box or list box, this field contains the value that was passed to the list box in the lParam parameter of one of the the following messages: | ||
CB_ADDSTRING | |||
CB_INSERTSTRING | |||
LB_ADDSTRING | |||
LB_INSERTSTRING | |||
For a menu, this field contains the DWORD value passed as the lpNewItem parameter of the InsertMenu which inserted the menu item. Its contents are undefined for buttons. |