次の方法で共有


CListBox::GetItemHeight

更新 : 2007 年 11 月

リスト ボックスの項目の高さを調べます。

int GetItemHeight(
   int nIndex 
) const;

パラメータ

  • nIndex
    リスト ボックスの項目を 0 から始まるインデックスで指定します。このパラメータは、リスト ボックスが 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);

必要条件

ヘッダー : afxwin.h

参照

参照

CListBox クラス

階層図

LB_GETITEMHEIGHT

CListBox::SetItemHeight

その他の技術情報

CListBox のメンバ