int GetHorizontalExtent( ) const;
Return Value
The scrollable width of the list box, in pixels.
Remarks
Retrieves from the list box the width in pixels by which it can be scrolled horizontally. This is applicable only if the list box has a horizontal scroll bar.
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 only if the current extent is not large enough.
if (pmyListBox->GetHorizontalExtent() < dx)
{
pmyListBox->SetHorizontalExtent(dx);
ASSERT(pmyListBox->GetHorizontalExtent() == dx);
}
CListBox Overview | Class Members | Hierarchy Chart
See Also CListBox::SetHorizontalExtent, LB_GETHORIZONTALEXTENT