Retaining Scroll Position

Started by
0 comments, last by RonHiler 17 years, 9 months ago
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);
ScrollInfo.fMask = SIF_ALL;
GetScrollInfo(AdvWinFeatList, SB_VERT, &ScrollInfo);
FillFeatSelectBox();             //this is where the contents get reset
ScrollInfo.fMask = SIF_POS ;
SetScrollInfo(AdvWinFeatList, SB_VERT, &ScrollInfo, true);
ScrollWindow(AdvWinFeatList, 0, -ScrollInfo.nPos, NULL, NULL);
UpdateWindow(AdvWinFeatList);

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]
Creation is an act of sheer will
Advertisement
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 :)
Creation is an act of sheer will

This topic is closed to new replies.

Advertisement