CListBox::GetItemHeight

确定高度列表框中的项。

int GetItemHeight(
   int nIndex 
) const;

参数

  • nIndex
    在列表框中指定项的从零开始的索引。 此参数,仅当列表框包含 LBS_OWNERDRAWVARIABLE 样式,使用;否则,应将其设置为0。

返回值

高度,均以像素,在列表框中的项。 如果列表框包含 LBS_OWNERDRAWVARIABLE 样式,则返回值是 nIndex指定的项的高度。 如果发生错误,则返回值是 LB_ERR

示例

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

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

要求

Header: afxwin.h

请参见

参考

CListBox选件类

层次结构图

LB_GETITEMHEIGHT

CListBox::SetItemHeight