# Retaining Scroll Position

This topic is 4376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Well, this seems like it ought to be quite simple, but in fact it has me stumped. I have a List Box that is Owner Drawn, created like so: AdvWinFeatList = CreateWindowEx(NULL, "LISTBOX", "Feat List", WS_CHILD | WS_VSCROLL | LBS_NOSEL | LBS_NOINTEGRALHEIGHT | LBS_OWNERDRAWFIXED | LBS_NOTIFY, 615, 215, 280, 240, Parent, (HMENU)MS_ADVWINFEATSLIST, Instance, NULL); If a user drags an icon off this box and drops it in a particular place, the contents of this window get reset. The problem with this is that resetting the content also causes the vscrollbar to reset to the top, which is undesirable. So, all I need to do is grab the position of the scrollbar, reset the box contents, and put the scroll position back. Seems easy, but it's making me nuts :) Here is the code I have to do this:
ScrollInfo.cbSize = sizeof(ScrollInfo);
FillFeatSelectBox();             //this is where the contents get reset


This does put the scrollbar where it's supposed to be, but the contents of the listbox appear as if the scrollbar is a the top. What in the world am I doing wrong here? Thanks -Ron [/source]

##### Share on other sites
Nevermind, I ripped all that nonsense out and just used LB_GETTOPINDEX and LB_SETTOPINDEX messages, and it worked just fine. All that was way too complex for such a simple task :)

1. 1
Rutin
19
2. 2
3. 3
JoeJ
15
4. 4
5. 5

• 21
• 19
• 11
• 13
• 17
• ### Forum Statistics

• Total Topics
631697
• Total Posts
3001763
×