CComboBox::GetItemHeight

int GetItemHeight( int nIndex ) const;

Return Value

The height, in pixels, of the specified item in a combo box. The return value is CB_ERR if an error occurs.

Parameters

nIndex

Specifies the component of the combo box whose height is to be retrieved. If the nIndex parameter is –1, the height of the edit-control (or static-text) portion of the combo box is retrieved. If the combo box has the CBS_OWNERDRAWVARIABLE style, nIndex specifies the zero-based index of the list item whose height is to be retrieved. Otherwise, nIndex should be set to 0.

Remarks

Call the GetItemHeight member function to retrieve the height of list items in a combo box.

Example

// The pointer to my combo box.
extern CComboBox* pmyComboBox;

// Set the height of every item so the item
// is completely visible.
CString str;
CSize   sz;
int     dx=0;
CDC*    pDC = pmyComboBox->GetDC();
for (int i=0;i < pmyComboBox->GetCount();i++)
{
   pmyComboBox->GetLBText( i, str );
   sz = pDC->GetTextExtent(str);

   // Only want to set the item height if the current height
   // is not big enough.
   if (pmyComboBox->GetItemHeight(i) < sz.cy)
      pmyComboBox->SetItemHeight( i, sz.cy );
}
pmyComboBox->ReleaseDC(pDC);

CComboBox OverviewClass MembersHierarchy Chart

See Also   CComboBox::SetItemHeight, WM_MEASUREITEM, CB_GETITEMHEIGHT