SetScrollPos

  int SetScrollPos(hwnd, fnBar, nPos, fRedraw)    
  HWND hwnd; /* handle of window with scroll bar */
  int fnBar; /* scroll bar flag */
  int nPos; /* new position of scroll box */
  BOOL fRedraw; /* redraw flag */

The SetScrollPos function sets the position of the scroll box (thumb) of the given scroll bar and, if requested, redraws the scroll bar to reflect the new position of the scroll box.

Parameters

hwnd

Identifies a scroll bar control or a window with a standard scroll bar, depending on the value of the fnBar parameter.

fnBar

Specifies the scroll bar to be set. This parameter can be one of the following values:

Value Meaning

SB_CTL  
  Sets the position of the scroll box in a scroll bar control. In this case, the hwnd parameter must be the handle of a scroll bar control.
SB_HORZ  
  Sets the position of the scroll box in a window's standard horizontal scroll bar.
SB_VERT  
  Sets the position of the scroll box in a window's standard vertical scroll bar.

nPos

Specifies the new position of the scroll box. The position must be within the scrolling range. For more information about the scrolling range, see the description of the SetScrollRange function.

fRedraw

Specifies whether the scroll bar should be redrawn to reflect the new scroll box position. If this parameter is TRUE, the scroll bar is redrawn. If it is FALSE, the scroll bar is not redrawn.

Return Value

The return value is the previous position of the scroll box, if the function is successful. Otherwise, it is zero. To obtain extended error information, use the GetLastError function.

Comments

Setting the fRedraw parameter to FALSE is useful if the scroll bar will be redrawn by a subsequent call to another function.

See Also

GetScrollPos, GetScrollRange, ScrollDC, ScrollWindow, SetScrollRange