DRAWITEMSTRUCT

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 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 with a WM_DRAWITEM message. For more information, see CWnd::OnDrawItem.

Members

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 member 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 member can be -1. 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 setting of the bits in the itemAction member 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 fol-lowing bits:

Value Meaning

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 member 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 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 dimmed, the state flag ODS_GRAYED will be set. The state flags are as follows:

Value Meaning

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 dimmed. This bit is used only in a menu.
ODS_SELECTED This 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. It contains the handle of the menu (HMENU) containing the item for menus.

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

itemData

Contains the owner-defined value that was assigned to this item when it was created.