MEASUREITEMSTRUCT

typedef struct tagMEASUREITEMSTRUCT {

WORD CtlType;

WORD CtlID;

WORD itemID;

WORD itemWidth;

WORD itemHeight;

DWORD itemData

} MEASUREITEMSTRUCT;

When an owner-draw control is created, Windows sends the WM_MEASUREITEM message to the owner of the control, along with a pointer to a MEASUREITEMSTRUCT data structure.

The MEASUREITEMSTRUCT data structure must be filled in order for Windows to process user interaction with the control correctly. For more information, see CWnd::OnMeasureItem.

The MEASUREITEMSTRUCT data structure informs Windows of the dimensions of an owner-draw control. This allows Windows to correctly process user interaction with the control. The owner of an owner-draw control receives a pointer to this structure as the lParam parameter of an WM_MEASUREITEM message. The owner-draw control sends this message to its owner window when the control is created. The owner then fills in the appropriate members in the structure for the control and returns. This structure is common to all owner-draw controls.

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 list-box item ID for a variable-height combo box or list box. This member is not used for a fixed-height combo box or list box, or for a button.

itemWidth

Specifies the width of a menu item. The owner of the owner-draw menu item must fill this member before returning from the message.

itemHeight

Specifies the height of an individual item in a list box or a menu. Before returning from the message, the owner of the owner-draw combo box, list box, or menu item must fill out this member. The maximum height of a list box item is 255.

itemData

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

Remarks

Failure to assign values to itemWidth and itemHeight members in the MEASUREITEMSTRUCT structure will cause improper operation of the control.