void SetHorizontalExtent( int cxExtent );
Parameters
cxExtent
Specifies the number of pixels by which the list box can be scrolled horizontally.
Remarks
Sets the width, in pixels, by which a list box can be scrolled horizontally. If the size of the list box is smaller than this value, the horizontal scroll bar will horizontally scroll items in the list box. If the list box is as large or larger than this value, the horizontal scroll bar is hidden.
To respond to a call to SetHorizontalExtent, the list box must have been defined with the WS_HSCROLL style.
This member function is not useful for multicolumn list boxes. For multicolumn list boxes, call the SetColumnWidth member function.
Example
// The pointer to my list box.
extern CListBox* pmyListBox;
// Find the longest string in the list box.
CString str;
CSize sz;
int dx=0;
CDC* pDC = pmyListBox->GetDC();
for (int i=0;i < pmyListBox->GetCount();i++)
{
pmyListBox->GetText( i, str );
sz = pDC->GetTextExtent(str);
if (sz.cx > dx)
dx = sz.cx;
}
pmyListBox->ReleaseDC(pDC);
// Set the horizontal extent so every character of all strings
// can be scrolled to.
pmyListBox->SetHorizontalExtent(dx);
CListBox Overview | Class Members | Hierarchy Chart
See Also CListBox::GetHorizontalExtent, CListBox::SetColumnWidth, LB_SETHORIZONTALEXTENT