SetScrollPos

2.x

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

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

Parameters

hwnd

Identifies the window whose scroll bar is to be set.

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. In this case, the hwnd parameter must be the handle of a scroll bar.
SB_HORZ Sets the position of the scroll box in a window's horizontal scroll bar.
SB_VERT Sets the position of the scroll box in a window's vertical scroll bar.

nPos

Specifies the new position of the scroll box. It must be within the scrolling range.

fRepaint

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

Return Value

The return value is the previous position of the scroll box, if the function is successful. Otherwise, it is zero.

Comments

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

See Also

GetScrollPos, GetScrollRange, ScrollWindow, SetScrollRange