SetScrollPos

Syntax

int SetScrollPos(hWnd,nBar,nPos,bRedraw)

This function sets the current position of a scroll-bar thumb to that specified by the nPos parameter and, if specified, redraws the scroll bar to reflect the new position.

Parameter Type/Description  

hWnd HWND Identifies the window whose scroll bar is to be set.  
nBar int Specifies the scroll bar to be set. It can be one of the following values:  
  Value Meaning
  SB_CTL Sets the position of a scroll-bar control. In this case, the hWnd parameter must be the handle of a scroll-bar control.
  SB_HORZ Sets a window's horizontal scroll-bar position.
  SB_VERT Sets a window's vertical scroll-bar position.
nPos int Specifies the new position. It must be within the scrolling range.  
bRedraw BOOL Specifies whether the scroll bar should be redrawn to reflect the new position. If the bRedraw parameter is nonzero, the scroll bar is redrawn. If it is zero, it is not redrawn.  

Return Value

The return value specifies the previous position of the scroll-bar thumb.

Comments

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