Condividi tramite


CComboBox::GetItemHeight

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

int GetItemHeight(
   int nIndex 
) const;

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.

Return Value

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

Example

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

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

Requirements

Header: afxwin.h

See Also

Reference

CComboBox Class

Hierarchy Chart

CComboBox::SetItemHeight

WM_MEASUREITEM

CB_GETITEMHEIGHT

Other Resources

CComboBox Members