次の方法で共有


CComboBox::GetItemHeight

更新 : 2007 年 11 月

コンボ ボックスのリスト項目の高さを取得します。

int GetItemHeight(
   int nIndex 
) const;

パラメータ

  • nIndex
    高さを取得するコンボ ボックスのコンポーネントを指定します。nIndex が -1 のときは、コンボ ボックスのエディット コントロール (または静的テキスト) 部分の高さを取得します。CBS_OWNERDRAWVARIABLE スタイルのコンボ ボックスの場合は、nIndex に、高さを取得するリスト項目を 0 から始まるインデックスで指定します。それ以外の場合は nIndex に 0 を指定します。

戻り値

コンボ ボックス内の指定した項目の高さをピクセル単位で返します。エラーが発生した場合は、CB_ERR を返します。

使用例

// 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);

必要条件

ヘッダー : afxwin.h

参照

参照

CComboBox クラス

階層図

CComboBox::SetItemHeight

WM_MEASUREITEM

CB_GETITEMHEIGHT

その他の技術情報

CComboBox のメンバ