I think you say, for example, how to handle the WM_VSCROLL / WM_HSCROLL event. If this is the first step, you need to handle this event. You should not use the HIWORD value (wParam) of this call, but use the GetScrollInfo, GetScrollPos, and GetScrollRange functions instead.
The following is an example of code cut off by MSDN - using scrollbars . xCurrentScroll is defined before by calling, for example, GetScrollPos ().
int xDelta; // xDelta = new_pos - current_pos int xNewPos; // new position int yDelta = 0; switch (LOWORD(wParam)) { // User clicked the scroll bar shaft left of the scroll box. case SB_PAGEUP: xNewPos = xCurrentScroll - 50; break; // User clicked the scroll bar shaft right of the scroll box. case SB_PAGEDOWN: xNewPos = xCurrentScroll + 50; break; // User clicked the left arrow. case SB_LINEUP: xNewPos = xCurrentScroll - 5; break; // User clicked the right arrow. case SB_LINEDOWN: xNewPos = xCurrentScroll + 5; break; // User dragged the scroll box. case SB_THUMBPOSITION: xNewPos = HIWORD(wParam); break; default: xNewPos = xCurrentScroll; } [...] // New position must be between 0 and the screen width. xNewPos = max(0, xNewPos); xNewPos = min(xMaxScroll, xNewPos); [...] // Reset the scroll bar. si.cbSize = sizeof(si); si.fMask = SIF_POS; si.nPos = xCurrentScroll; SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
source share