void ScrollTo(HWND hwnd, struct ClcData *dat, int desty, int noSmooth) { DWORD startTick, nowTick; int oldy = dat->yScroll; RECT clRect, rcInvalidate; int maxy, previousy; if (dat->iHotTrack != -1 && dat->yScroll != desty) { pcli->pfnInvalidateItem(hwnd, dat, dat->iHotTrack); dat->iHotTrack = -1; ReleaseCapture(); } GetClientRect(hwnd, &clRect); rcInvalidate = clRect; maxy = RowHeight::getTotalHeight(dat)-clRect.bottom; if (desty > maxy) desty = maxy; if (desty < 0) desty = 0; if (abs(desty - dat->yScroll) < 4) noSmooth = 1; if ( !noSmooth && dat->exStyle & CLS_EX_NOSMOOTHSCROLLING) noSmooth = 1; previousy = dat->yScroll; if ( !noSmooth) { startTick = GetTickCount(); for (; ;) { nowTick = GetTickCount(); if (nowTick >= startTick + dat->scrollTime) break; dat->yScroll = oldy + (desty - oldy) * (int) (nowTick - startTick) / dat->scrollTime; if (dat->backgroundBmpUse & CLBF_SCROLL || dat->hBmpBackground == NULL) ScrollWindowEx(hwnd, 0, previousy - dat->yScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE); else InvalidateRect(hwnd, NULL, FALSE); previousy = dat->yScroll; if (cfg::dat.bSkinnedScrollbar && !dat->bisEmbedded) CoolSB_SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE); else SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE); UpdateWindow(hwnd); } } dat->yScroll = desty; if (dat->backgroundBmpUse & CLBF_SCROLL || dat->hBmpBackground == NULL) { if ( !noSmooth) ScrollWindowEx(hwnd, 0, previousy - dat->yScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE); else InvalidateRect(hwnd, NULL, FALSE); } else InvalidateRect(hwnd, NULL, FALSE); if (cfg::dat.bSkinnedScrollbar && !dat->bisEmbedded) CoolSB_SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE); else SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE); dat->forceScroll = 0; }
// // Child window procedure // LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static int count; char ach[80]; switch(msg) { case WM_VSCROLL: switch(LOWORD(wParam)) { case SB_LINEUP: nVScrollPos --; break; case SB_LINEDOWN: nVScrollPos ++; break; case SB_PAGEUP: nVScrollPos -= nVScrollPage; break; case SB_PAGEDOWN: nVScrollPos += nVScrollPage; break; case SB_TOP: nVScrollPos = 0; break; case SB_BOTTOM: nVScrollPos = nVScrollMax -1; break; case SB_THUMBTRACK: nVScrollPos = HIWORD(wParam); break; } wsprintf(ach, "WM_VSCROLL %d\n", count++); OutputDebugString(ach); if(nVScrollPos < 0) nVScrollPos = 0; if(nVScrollPos > nVScrollMax - nVScrollPage + 1) nVScrollPos = nVScrollMax - nVScrollPage + 1; CoolSB_SetScrollPos(hwnd, SB_VERT, nVScrollPos, TRUE); return 0; case WM_HSCROLL: wsprintf(ach, "WM_HSCROLL %d\n", count++); OutputDebugString(ach); switch(LOWORD(wParam)) { case SB_LINEUP: nHScrollPos --; break; case SB_LINEDOWN: nHScrollPos ++; break; case SB_PAGEUP: nHScrollPos -= nHScrollPage; break; case SB_PAGEDOWN: nHScrollPos += nHScrollPage; break; case SB_TOP: nHScrollPos = 0; break; case SB_BOTTOM: nHScrollPos = nHScrollMax -1; break; case SB_THUMBTRACK: nHScrollPos = HIWORD(wParam); break; } if(nHScrollPos < 0) nHScrollPos = 0; if(nHScrollPos > nHScrollMax - nHScrollPage + 1) nHScrollPos = nHScrollMax - nHScrollPage + 1; CoolSB_SetScrollPos(hwnd, SB_HORZ, nHScrollPos, TRUE); return 0; case WM_SIZE: SetupScrollbars(hwnd); return 0; } return DefWindowProc(hwnd, msg, wParam, lParam); }