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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box scrolling issues

Status
Not open for further replies.

List

Technical User
Apr 22, 2004
5
PE
Hello there,
ok...this is what i wish to achieve. I want to program the scroll bar of the list box such that it is always at the bottom and such that i can always see the most recently added string (the strings are being added at a constant rate of 1 string per second.).
By default the scroll bar is always on top and the freshly added strings disappear from sight once they increase beyond the height of the list box.
I've tried implementing pretty much every available function but to no avail. Even if I get my scroll bar to be positioned at the bottom, the window refuses to scroll up and the newly added strings are hidden from view.
Am running out of ideas ..any suggestions?

Wooster.
 
Hmmm...what I'm getting is that you want your list to be always scrolled at the bottom so you can see your newly added strings? Well, I think you may have two options. One option is to have it so when you add the string to the list, it adds it to the TOP of the list. That way you don't have to keep scrolling to the bottom to see the newly added string. That would be the most visually pleasing. When you add strings to the bottom, I think the list will ALWAYS scroll back to the top...so if you do scroll to the bottom every time a string is added, there will be a lot of "jumping" around in the list box...but, try this if you still want to do that:

First get the handle to the list box, then use this to get your maximum scroll range of the list box:

int MaxScrollRange;
int MinScrollRange;

GetScrollRange(HandleToYourList, SB_VERT, &MaxScrollRange, &MinScrollRange);

SetScrollPos(HandleToYourList, SB_VERT, MaxScrollRange, true);

Something like this should do it. The reason you are sending the addresses of the variables Max/MinScrollRange to GetScrollRange() is because the function actually calls for a LPINT type. Like I said, adding the string to the top of your list may be easier than doing the scrolling. Lemme know if you need any other help.

Niky Williams
Lead Engineer
NTS Marketing, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top