Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CListBox::GetHorizontalExtent

 

Retrieves from the list box the width in pixels by which it can be scrolled horizontally.


int GetHorizontalExtent( ) const;

The scrollable width of the list box, in pixels.

This is applicable only if the list box has a horizontal scroll bar.

Example

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

Requirements

Header: afxwin.h

Show: