Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Horizontal scroll bar not enabled

Status
Not open for further replies.

zulfi1234

Instructor
Jul 2, 2000
32
PK
I have created two list boxes: single line & multiline . The vertical scroll bar becomes enabled when the<br>&nbsp;limit crosses but horizontal scroll bar is not enabled in both the list boxes despite the fact that length of<br>&nbsp;text is greater than the size of list box.<br><br><br>&nbsp;Zulfi.
 
Did you check the 'Horizontal Scroll' check box on the 'Styles' tab of the 'List Box Properties' dialog?<br><br>-pete
 
I have&nbsp;&nbsp;already&nbsp;&nbsp;checked it.<br><br>Actually&nbsp;&nbsp;problem&nbsp;&nbsp;is&nbsp;&nbsp;with&nbsp;&nbsp;Multi-Line&nbsp;&nbsp;list&nbsp;&nbsp;box. Its&nbsp;&nbsp;working for&nbsp;&nbsp;Single Line.<br><br>My problem&nbsp;&nbsp;not&nbsp;&nbsp;solved.
 
ummm... oops, I apologize, it's been so long since I've worked with a list box I forgot how they work. You will need to either guess or calculate the pixel width of the longest string in you list box and then call the CListBox.SetHorizontalExtent( nExtent) member to tell the listbox control what the width is.<br><br>Do you know how to calculate the pixel width of a string?<br><br>-pete
 
I have&nbsp;&nbsp;tried&nbsp;&nbsp;with&nbsp;&nbsp;the&nbsp;&nbsp;following&nbsp;&nbsp;code but its not working. <br><br>m_MultiList.AddString(&quot;One Two Three HHHHHHHHHH&quot;);<br> m_MultiList.AddString(&quot;Four Five Six&quot;);<br> m_MultiList.AddString(&quot;Seven Eight Nine&quot;);<br><br><br>CString str;<br>&nbsp;CSize&nbsp;&nbsp;&nbsp;sz;<br>&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nPix=0;<br>&nbsp;int nCount = m_MultiList.GetCount();<br>&nbsp;CDC*&nbsp;&nbsp;&nbsp;&nbsp;pDC = m_MultiList.GetDC();<br>&nbsp;for ( i=0;i &lt; nCount;i++)<br>&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;m_MultiList.GetText( i, str );<br>&nbsp;&nbsp;&nbsp;&nbsp;sz = pDC-&gt;GetTextExtent(str);<br>&nbsp;&nbsp;&nbsp;&nbsp;if (sz.cx &gt; nPix)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nPix = sz.cx;<br>&nbsp;}<br>&nbsp;m_MultiList.ReleaseDC(pDC);<br>&nbsp;m_MultiList.SetHorizontalExtent(nPix);<br> }<br><br>I have also tried with SetColumnWidth&nbsp;&nbsp;but its not working.<br><br><br>My&nbsp;&nbsp;problem&nbsp;&nbsp;not&nbsp;&nbsp;solved.<br><br><br>Zulfi.
 
Dear Zulfi,<br><br>Try a hardcoded value just to see what happens. This make sure the width of your list box is small (not 300 or larger), then this should produce a horizontal scrollbar:<br><br>m_MultiList.SetHorizontalExtent( 300);<br><br>Let my know<br>-pete
 
Hi, I have hard coded&nbsp;&nbsp;the&nbsp;&nbsp;value but its still not working.<br><br>Please help&nbsp;&nbsp;me.<br><br>My&nbsp;&nbsp;problem&nbsp;&nbsp;not&nbsp;&nbsp;solved.<br><br>Zulfi.
 
Dear zulfi1234,<br><br>Every time I repeat the procedure within different projects and on different dialogs it works everytime. There must be something specific to your code or project or environment that is causing the problem.<br><br>Can you make a .zip file available on a web page for download? Or do you have any other ideas?<br><br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top