次の方法で共有


CComboBox::GetHorizontalExtent

更新 : 2007 年 11 月

コンボ ボックスのリスト ボックスで水平方向にスクロールできる幅 (ピクセル単位) をコンボ ボックスから取得します。

UINT GetHorizontalExtent( ) const;

戻り値

コンボ ボックスのリスト ボックスでスクロールできる幅をピクセル単位で返します。

解説

コンボ ボックスのリスト ボックスに水平スクロール バーがある場合だけ適用されます。

使用例

// Find the longest string in the combo box.
CString strText;
CSize   sz;
UINT    dxText = 0;
CDC*    pDCCombo = m_pComboBox->GetDC();
for (int i = 0; i < m_pComboBox->GetCount(); i++)
{
   m_pComboBox->GetLBText(i, strText);
   sz = pDCCombo->GetTextExtent(strText);

   if (sz.cx > (LONG)dxText)
     dxText = sz.cx;
}
m_pComboBox->ReleaseDC(pDCCombo);

// Set the horizontal extent only if the current extent is not large enough.
if (m_pComboBox->GetHorizontalExtent() < dxText)
{
   m_pComboBox->SetHorizontalExtent(dxText);
   ASSERT(m_pComboBox->GetHorizontalExtent() == dxText);
}

必要条件

ヘッダー : afxwin.h

参照

参照

CComboBox クラス

階層図

CListBox::SetHorizontalExtent

CB_GETHORIZONTALEXTENT

その他の技術情報

CComboBox のメンバ