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