Hello, I'm using Microsoft Visual C++ 5.0, and am trying to make the horizontal scroll bars work the want I want them to for a CListBox. Here's a sample of what my code currently does:
When I do it this way, the horizontal scroll bar is just set to a number of pixels in width, and may scroll way too far, or not far enough. I want to it to set the horizontal scroll bar to be the width of the longest string I add to the list box. How do I determine the length in pixels of each string?Code:CListBox *listBox; listBox = (CListBox*)GetDlgItem(IDC_MY_LIST_BOX); int n; listBox->SetHorizontalExtent(500); for (n = 0; n < 10; n++) { listBox->AddString(text[n]); // assume text is a char array }
If I don't use SetHorizontalExtent, then it won't display horizontal scroll bars for my list box, even when text scrolls off the screen to the right. If I force it to display all the scroll bars, the horizontal scroll bar just doesn't become active, even though text is still scrolling off to the right. Any ideas?



LinkBack URL
About LinkBacks


