CListBox::GetHorizontalExtent

更新 : 2007 年 11 月

リスト ボックスから、水平スクロール可能な幅をピクセル単位で取得します。

int GetHorizontalExtent( ) const;

戻り値

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

解説

リスト ボックスが水平スクロール バーを持つ場合にのみ有効です。

使用例

// Find the longest string in the list box.
CString str;
CSize   sz;
int     dx=0;
CDC*    pDC = m_myListBox.GetDC();
for (int i=0;i < m_myListBox.GetCount();i++)
{
   m_myListBox.GetText( i, str );
   sz = pDC->GetTextExtent(str);

   if (sz.cx > dx)
      dx = sz.cx;
}
m_myListBox.ReleaseDC(pDC);

// Set the horizontal extent only if the current extent is not large enough.
if (m_myListBox.GetHorizontalExtent() < dx)
{
   m_myListBox.SetHorizontalExtent(dx);
   ASSERT(m_myListBox.GetHorizontalExtent() == dx);
}

必要条件

ヘッダー : afxwin.h

参照

参照

CListBox クラス

階層図

CListBox::SetHorizontalExtent

LB_GETHORIZONTALEXTENT

その他の技術情報

CListBox のメンバ