CMenu::MeasureItem

Called by the framework when a menu with the owner-draw style is created.

virtual void MeasureItem( 
   LPMEASUREITEMSTRUCT lpMeasureItemStruct  
);

Parameters

  • lpMeasureItemStruct
    A pointer to a MEASUREITEMSTRUCT structure.

Remarks

By default, this member function does nothing. Override this member function and fill in the MEASUREITEMSTRUCT structure to inform Windows of the menu's dimensions.

See CWnd::OnMeasureItem for a description of the MEASUREITEMSTRUCT structure.

Example

The following code is from the MFC CTRLTEST sample:

// Override MeasureItem() to return the size of the menu item. 
// CColorMenu is a CMenu-derived class. 

#define COLOR_BOX_WIDTH     20
#define COLOR_BOX_HEIGHT    20


void CColorMenu::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
   // all items are of fixed size
   lpMIS->itemWidth = COLOR_BOX_WIDTH;
   lpMIS->itemHeight = COLOR_BOX_HEIGHT;
}

Requirements

Header: afxwin.h

See Also

Reference

CMenu Class

Hierarchy Chart

Other Resources

CMenu Members