i'm testing the win32 scrollbars, but i'm with 1 problem: when i use the SB_THUMBPOSITION message, why the window isn't repainted( the WM_PAINT message isn't used)?

case WM_VSCROLL:
            switch (LOWORD (wParam))
            {
                case SB_LINEUP:
                    VerticalScroll-=1;
                    break;
                case SB_LINEDOWN:
                    VerticalScroll+=1;
                    break;
                case SB_THUMBPOSITION:
                    VerticalScroll=HIWORD (wParam);
                    break;
                case SB_PAGEDOWN:
                    VerticalScroll+=10;
                    break;
                case SB_PAGEUP:
                    VerticalScroll-=10;
                    break;
            }
            SetScrollPos (hwnd, SB_VERT, VerticalScroll, TRUE) ;
            InvalidateRect(hwnd,NULL,TRUE);
            return 0;

MSDN Says:

Note The SetScrollPos function is provided for backward compatibility. New applications should use the SetScrollInfo function.

I think you need to call GetScrollPos first to get the current position then call SetScrollPos to change it.

commented: thanks +2

isn't that problem. the problem was that i didn't use the SB_THUMBTRACK scrollbar message.

case WM_VSCROLL:
            si.cbSize = sizeof(si);
            si.fMask  = SIF_ALL;
            GetScrollInfo (hwnd, SB_VERT, &si);
            switch (LOWORD (wParam))
            {
                case SB_TOP:
                    VerticalScroll=0;
                    return 0;
                case SB_BOTTOM:
                    VerticalScroll=VerticalScrollSize;
                    return 0;
                case SB_LINEUP:
                    VerticalScroll-=ScrollMove;
                    break;
                case SB_LINEDOWN:
                    VerticalScroll+=ScrollMove;
                    break;
                case SB_THUMBPOSITION:
                    VerticalScroll=HIWORD (wParam);
                    break;
                case SB_THUMBTRACK:
                    VerticalScroll=HIWORD (wParam);
                    break;
                case SB_PAGEDOWN:
                    VerticalScroll+=ScrollMove*10;
                    break;
                case SB_PAGEUP:
                    VerticalScroll-=ScrollMove*10;
                    break;
            }
            if (VerticalScroll<=0) VerticalScroll=0;
            if (VerticalScroll>=VerticalScrollSize) VerticalScroll=VerticalScrollSize;
            si.nMin = 0;
            si.nPos = VerticalScroll;
            si.nMax = VerticalScrollSize-2;
            si.nPage=2;
            SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
            InvalidateRect(hwnd, NULL, TRUE);
            return 0;

now works fine.. thanks
and yes i must use the ScrollInfo() functions with SCROLLINFO structure.
i hope these problem helps others ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.