Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Determines the height of items in a list box.
int GetItemHeight(
int nIndex
) const;
Parameters
- nIndex
Specifies the zero-based index of the item in the list box. This parameter is used only if the list box has the LBS_OWNERDRAWVARIABLE style; otherwise, it should be set to 0.
Return Value
The height, in pixels, of the items in the list box. If the list box has the LBS_OWNERDRAWVARIABLE style, the return value is the height of the item specified by nIndex. If an error occurs, the return value is LB_ERR.
Example
// 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);
Requirements
Header: afxwin.h