WM_MEASUREITEM

3.0

WM_MEASUREITEM
nIDCtl = (int) wParam;                      /* control identifier   */
lpmisCtl = (MEASUREITEMSTRUCT FAR*) lParam; /* address of structure */

The WM_MEASUREITEM message is sent to the owner of an owner-drawn button, combo box, list box, or menu item when the control is created. When the owner receives the message, the owner fills in the MEASUREITEMSTRUCT structure pointed to by the lpmisCtl message parameter and returns; this informs Windows of the dimensions of the control. If a list box or combo box is created with the LBS_OWNERDRAWVARIABLE or CBS_OWNERDRAWVARIABLE style, this message is sent to the owner for each item in the control; otherwise, this message is sent once.

Parameters

nIDCtl

Value of wParam. Specifies the identifier of the control that sent the WM_MEASUREITEM message. This parameter is 0 if the message was sent by a menu. This parameter is –1 when the system is requesting the dimensions of an edit control in an owner-drawn combo box.

lpmisCtl

Value of lParam. Points to a MEASUREITEMSTRUCT structure that contains the dimensions of the owner-drawn control.

The MEASUREITEMSTRUCT structure has the following form:

typedef struct tagMEASUREITEMSTRUCT {   /* mi */
    UINT   CtlType;
    UINT   CtlID;
    UINT   itemID;
    UINT   itemWidth;
    UINT   itemHeight;
    DWORD  itemData;
} MEASUREITEMSTRUCT;

Return Value

An application should return TRUE if it processes this message.

Comments

Windows sends the WM_MEASUREITEM message to the owner of a combo box or list box created with the OWNERDRAWFIXED style before sending WM_INITDIALOG. As a result, when the owner receives this message, Windows has not yet determined the height and width of the font used in the control; function calls and calculations requiring these values should occur in the main function of the application or library.

See Also

WM_COMPAREITEM, WM_DELETEITEM, WM_DRAWITEM, WM_INITDIALOG