Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


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.

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

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

Header: afxwin.h

© 2015 Microsoft