VScroll not quite working

This is a discussion on VScroll not quite working within the Windows Programming forums, part of the Platform Specific Boards category; Ok, this is starting to annoy me. I've looked at two different examples (MSDN and petzold) of a scrollbar control ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    161

    VScroll not quite working

    Ok, this is starting to annoy me. I've looked at two different examples (MSDN and petzold) of a scrollbar control and handling the WM_VSCROLL and I still can't get the damn box on the bar to reposition itself when I drag it. I realize it's not moving the box when I click anywhere else either, but it's giving the desired effect anyway; at least that tells me I'm processing the right message. One example I saw used SB_THUMBTRACK and one used SB_THUMBPOSITION. Which do I want to process, or both?

    p.s. Unless there's a way to force a scrollbar to appear on a listview, don't knock my implementation. It'll suit my purpose. I just want to know how to make the bloody box move, please.

    Code:
        SCROLLINFO si;
        si.cbSize = sizeof(si);
        si.fMask  = SIF_RANGE | SIF_PAGE;
        si.nMin   = 0;
        si.nMax   = MaxResNum;
        si.nPage  = SendMessage(hResList,LVM_GETCOUNTPERPAGE,0,0);
        SetScrollInfo(hResScroll, SB_VERT, &si, TRUE);
    Code:
            case WM_VSCROLL:
            {
                if (((HWND)lParam != hResScroll) || (!(ResultsList))) { break; }
                int PageSize = SendMessage(hResList,LVM_GETCOUNTPERPAGE,0,0);
                SCROLLINFO si;
                si.cbSize = sizeof(si);
                si.fMask  = SIF_ALL;
                GetScrollInfo (hResScroll, SB_VERT, &si);
                switch(LOWORD(wParam))
                {
                    case SB_LINEDOWN:
                    {
                        CurrResNum = ShowResPage(CurrResNum + 1);
                    } break;
                    case SB_PAGEDOWN:
                    {
                        CurrResNum = ShowResPage(CurrResNum + PageSize);
                    } break;
                    case SB_LINEUP:
                    {
                        CurrResNum = ShowResPage(CurrResNum - 1);
                    } break;
                    case SB_PAGEUP:
                    {
                        CurrResNum = ShowResPage(CurrResNum - PageSize);
                    } break;
                    case SB_THUMBTRACK:
                    {
                        si.fMask = SIF_POS;
                        si.nPos += 1;
                        SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
                        CurrResNum = ShowResPage(si.nPos);
                    } break;
                    default: return FALSE;
                }
    Last edited by Viper187; 10-08-2008 at 08:52 PM.

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by Viper187 View Post
    Which do I want to process, or both?
    Both. They do two different things. One is for one when someone moves the scroll thingy. The other is for one someone is clicking the buttons or outside the scroll-a-majig.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    161
    I'm still getting nothing. The button on the bar won't even move up/down when I click the arrows. What am I doing wrong???

    Code:
            case WM_VSCROLL:
            {
                if (((HWND)lParam != hResScroll) || (!(ResultsList))) { break; }
                int PageSize = SendMessage(hResList,LVM_GETCOUNTPERPAGE,0,0);
                SCROLLINFO si;
                si.cbSize = sizeof(SCROLLINFO);
                si.fMask  = SIF_ALL;
                GetScrollInfo (hResScroll, SB_VERT, &si);
                switch(LOWORD(wParam))
                {
                    case SB_LINEDOWN:
                    {
                        si.nPos += 1;
                        CurrResNum = ShowResPage(CurrResNum + 1);
                    } break;
                    case SB_PAGEDOWN:
                    {
                        si.nPos += si.nPage;
                        CurrResNum = ShowResPage(CurrResNum + PageSize);
                    } break;
                    case SB_LINEUP:
                    {
                        si.nPos -= 1;
                        CurrResNum = ShowResPage(CurrResNum - 1);
                    } break;
                    case SB_PAGEUP:
                    {
                        si.nPos -= si.nPage;
                        CurrResNum = ShowResPage(CurrResNum - PageSize);
                    } break;
                    case SB_THUMBTRACK:
                    {
                        si.nPos = si.nTrackPos;
                    } break;
                    default: break;
                }
                si.fMask = SIF_POS;
                SetScrollInfo (hResScroll, SB_VERT, &si, TRUE);
    Last edited by Viper187; 10-08-2008 at 11:27 PM.

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    161
    Ok, a week later I still didn't figure out my problem. Why doesn't it work!?

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Sorry Viper187. I know sometimes the mods get ........ed, but in the future just bump the thread sooner. Sometimes I just miss them because I accidentally mark all the forums as read.

    Quote Originally Posted by M$DN
    WM_VSCROLL

    The high-order word specifies the current position of the scroll box if the low-order word is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, this word is not used.
    You need to actually check which is occuring, bud.

  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    161
    I tried. It doesn't work. I can't ever get that stupid box to move.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 08:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 04:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 08:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 08:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 05:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21