DRAWITEMSTRUCT

3.0

typedef struct tagDRAWITEMSTRUCT {  /* ditm */
    UINT  CtlType;
    UINT  CtlID;
    UINT  itemID;
    UINT  itemAction;
    UINT  itemState;
    HWND  hwndItem;
    HDC   hDC;
    RECT  rcItem;
    DWORD itemData;
} DRAWITEMSTRUCT;

The DRAWITEMSTRUCT structure provides information the owner needs to determine how to paint an owner-drawn control. The owner of the owner-drawn control receives a pointer to this structure as the lParam parameter of the WM_DRAWITEM message.

Members

CtlType

Specifies the control type. The values for control types follow:

Value Meaning

ODT_BUTTON Owner-drawn button
ODT_COMBOBOX Owner-drawn combo box
ODT_LISTBOX Owner-drawn list box
ODT_MENU Owner-drawn menu

CtlID

Specifies the control identifier for a combo box, list box or button. This member is not used for a menu.

itemID

Specifies the menu-item identifier 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 member is a negative value. This allows the application to draw only the focus rectangle at the coordinates specified by the rcItem member 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 itemAction member determines whether the rectangle is to be drawn as though the list box or combo box has input focus.

itemAction

Specifies the drawing action required. This member is one or more of the following values:

Value Meaning

ODA_DRAWENTIRE Bit is set when the entire control needs to be drawn.
ODA_FOCUS Bit is set when the control gains or loses input focus. The itemState member should be checked to determine whether the control has focus.
ODA_SELECT Bit is set when only the selection status has changed. The itemState member 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. Following are the state flags:

Value Meaning

ODS_CHECKED Bit is set if the menu item is to be checked. This bit is used only in a menu.
ODS_DISABLED Bit is set if the item is to be drawn as disabled.
ODS_FOCUS Bit is set if the item has input focus.
ODS_GRAYED Bit is set if the item is to be grayed. This bit is used only in a menu.
ODS_SELECTED Bit is set if the item's status is selected.

hwndItem

Specifies the window handle of the control for combo boxes, list boxes, and buttons. 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

Specifies a rectangle in the device context identified by the hDC member 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 it does not clip menu items. When drawing menu items, it must ensure that the owner does not draw outside the boundaries of the rectangle defined by the rcItem member.

itemData

Contains the value last assigned to the list box or combo box by an LB_SET-ITEMDATA or CB_SETITEMDATA message. If the list box or combo box has the LBS_HASSTRINGS or CBS_HASSTRINGS style, this value is initially zero. Otherwise, this value is initially the value that was passed to the list box or combo box in the lParam parameter of one of the following messages:

CB_ADDSTRING CB_INSERTSTRING LB_ADDSTRING LB_INSERTSTRING