Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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);
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);

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 this post

Link to post
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 :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!