标题：SetScrollPos
函数功能
该函数设置所指定滚动条中的滚动按钮的位置，如果需要，可重绘滚动条以反映出滚动按钮的新位置。该函数提供了向后兼容性，新的应用程序应使用SetScrolllnfo函数。
函数原型
int SetScrollPos(
HWND
参数
hWnd 
[输入] 滚动条控件或带有标准滚动条窗体的句柄，由nBar参数值确定
nBar 
[输入] 指定滚动条将被设置。这个参数可以是下表值中的一个，含义如下：
﻿值说明﻿﻿﻿SB_CTL﻿﻿﻿设置滚动条控件的范围。而参数hwnd必须是滚动条控件的句柄。﻿﻿SB_HORZ﻿设置窗体的标准水平滚动条的范围。 ﻿﻿SB_VERT﻿﻿设置窗体的标准垂直滚动条的范围
nPos 
[输入] 指定滚动按钮的新位置。这个位置必须在滚动范围之内。若要了解更多有关滚动范围的信息，请参见SetScrollRange函数。
bRedraw 
[输入] 指定滚动条是否被重画以反映变化。如果这个参数为TRUE，滚动条将被重画；如果为FALSE则不被重画。　
返回值
如果函数运行成功，其返回值是滚动按钮的前一个位置。
如果函数运行失败，其返回值是0。
若想获得更多的错误信息，请调用GetLastError函数。
Windows XP: 如果the desktop is themed 并且父窗口是一个 message-only window ，则函数返回一个不真实的值。
备注
如果后续又调用了会重绘滚动条的函数，那么设置参数bRedraw为FALSE是非常有必要的。
因为说明滚动条位置的消息WM_HSCROLL和 WM_VSCROLL只能为16位数据，那些只依赖于说明位置数据消息的应用程序在函数SetScrollPos的参数nMaxPos中有一个实际最大值65,535 。
但是，因为函数SetScrolllnfo，SetScrollPos， SetScrollRange，GetScrolllnfo，GetScrollPos，和GetScrollRange都支持32位的滚动条位置数据，所以有一个解决16位WM_HSCROLL和WM_VSCROLL消息阻碍的途径，请参见函数GetScrolllnfo的有关技术说明。
速查
Windows NT 3.1、Windows 95、Windows CE 2.0以上，头文件：winuser.h；库文件：user32.lib。
英文原文
SetScrollPos Function
--------------------------------------------------------------------------------
The SetScrollPos function sets the position of the scroll box (thumb) in the specified scroll bar and, if requested, redraws the scroll bar to reflect the new position of the scroll box. 
Note The SetScrollPos function is provided for backward compatibility. New applications should use the SetScrollInfo function.
Syntax
int SetScrollPos( HWND hWnd,
int nBar,
int nPos,
BOOL bRedraw
);
Parameters
hWnd
Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter. 
nBar
Specifies the scroll bar to be set. This parameter can be one of the following values. 
SB_CTL
Sets the position of the scroll box in a scroll bar control. The hwnd parameter must be the handle to the 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 SetScrollRange function. 
bRedraw
Specifies whether the scroll bar is 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
If the function succeeds, the return value is the previous position of the scroll box. 
Windows XP: If the desktop is themed and the parent window is a message-only window, the function returns an incorrect value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
If the scroll bar is redrawn by a subsequent call to another function, setting the bRedraw parameter to FALSE is useful. 
Because the messages that indicate scroll bar position, WM_HSCROLL and WM_VSCROLL, are limited to 16 bits of position data, applications that rely solely on those messages for position data have a practical maximum value of 65,535 for the SetScrollPos function's nPos parameter. 
However, because the SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRange functions 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 GetScrollInfo for a description of the technique. 
If the nBar parameter is SB_CTL and the window specified by the hWnd parameter is not a system scroll bar control, the system sends the SBM_SETPOS message to the window to set scroll bar information. This allows SetScrollPos to operate on a custom control that mimics a scroll bar. If the window does not handle the SBM_SETPOS message, the SetScrollPos function fails. 
Function Information
Minimum DLL Version user32.dll 
Header Declared in Winuser.h, include Windows.h 
Import library User32.lib 
Minimum operating systems Windows 95, Windows NT 3.1 
See Also
Scroll Bars, GetScrollInfo, GetScrollPos, GetScrollRange, SetScrollInfo, SetScrollRange