Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This message is sent to a window when a scroll event occurs in the window's standard horizontal scroll bar. This message is also sent to the owner of a horizontal scroll bar control when a scroll event occurs in the control.
WM_HSCROLL nScrollCode= (int)LOWORD( wParam); nPos= (short int)HIWORD( wParam); hwndScrollBar= (HWND) lParam;
Parameters
Value | Description |
---|---|
SB_ENDSCROLL | Ends scroll. |
SB_LEFT | Scrolls to the upper left. |
SB_RIGHT | Scrolls to the lower right. |
SB_LINELEFT | Scrolls left by one unit. |
SB_LINERIGHT | Scrolls right by one unit. |
SB_PAGELEFT | Scrolls left by the width of the window. |
SB_PAGERIGHT | Scrolls right by the width of the window. |
SB_THUMBPOSITION | The user has dragged the scroll box (thumb) and released the mouse button. The nPosparameter indicates the position of the scroll box at the end of the drag operation. |
SB_THUMBTRACK | The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The nPosparameter indicates the position that the scroll box has been dragged to. |
Return Values
An application should return zero if it processes this message.
Remarks
The SB_THUMBTRACK notification message is typically used by applications that provide feedback as the user drags the scroll box.
If an application scrolls the content of the window, it must also reset the position of the scroll box by using the SetScrollPosfunction.
When the range of scroll bar uses a non-zero value for the minimum position, SB_THUMBTRACK and SB_THUMBPOSITION notifications report the current position incorrectly. The SB_THUMBPOSITION maps the scroll bar range to 0 - (max-min). The following code example shows how to work around this problem by adding your minimum to the nPosvalue passed in with this message.
case WM_VSCROLL: { int nScrollCode = (int)LOWORD(wParam); int nPos = (short int)HIWORD(wParam); SCROLLINFO si = {sizeof(SCROLLINFO), SIF_PAGE|SIF_POS|SIF_RANGE|SIF_TRACKPOS, 0, 0, 0, 0, 0}; GetScrollInfo (hWnd, SB_VERT, &si); int nNewPos = si.nPos; switch (nScrollCode) { // Include code that checks for other values of nScrollCode. // ... case SB_THUMBPOSITION: nNewPos = nPos + si.nMin; // Adding si.nMin is the workaround. break; } si.fMask = SIF_POS; si.nPos = nNewPos; SetScrollInfo (hWnd, SB_VERT, &si, TRUE); } return TRUE;
Note that the WM_HSCROLL message carries only 16 bits of scroll box position data. Thus, applications that rely solely on WM_HSCROLL (and WM_VSCROLL) for scroll position data have a practical maximum position value of 65,535.
However, because the SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRangefunctions support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the WM_HSCROLL and WM_VSCROLL messages. See GetScrollInfofor a description of the technique.
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 1.0 and later | Winuser.h |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
GetScrollInfo, SetScrollPos, SetScrollRange, WM_VSCROLL