Hi
It's not sufficient to set the listbox style. You also have to call the function SetHorizontalExtent and pass to it the maximum width of the strings of the listbox.
If this max. width is greater than the width of the list box, the scrollbar will be displayed.
As an example, here is the kind of code you can use. I declare the listbox with ClassWizard as m_List. I add some stupid strings with different width for the demo ...
CSize sizeText;
CString str;
CDC* pdc = m_List.GetWindowDC();
CFont* pFont = m_List.GetFont();
CFont* pOldFont = pdc->SelectObject( pFont);
for ( int x = 1; x < 30; x++)
{
sizeText = pdc->GetTextExtent( str);
m_List.SetHorizontalExtent( sizeText.cx + 10);
str.Format( "This is string %ld and it's larger than the listbox", x*x*x*x);
m_List.AddString( str);
}
pdc->SelectObject( pOldFont);
ReleaseDC( pdc);
HTH
Thierry
EMail: Thierry.Marneffe@swing.be