读书人

滚动条使用

发布时间: 2013-09-06 10:17:17 作者: rapoo

滚动条使用求助
在WM_CREATE消息中用CreateWindow创建滚动条控件,hWndScroll是先定义的静态HWND型变量,创建如下:
hWndScroll = CreateWindow("SCROLLBAR",NULL,WS_CHILD|WS_VISIBLE|SBS_HORZ,
10,10,400,40,hwnd,(HMENU)NULL,hInstance,NULL);
创建后我用SetScrollRange函数指定滚动条范围,指定范围代码如下:SetScrollRange(hWndScroll,SB_HORZ,0,350,FALSE);
但是运行后在原滚动条下又出现一个滚动条,把SetScrollRange函数的第二个参数SB_HORZ改为SB_CTL后就正常,请问是什么原因,请高手帮忙解答,多谢!
[解决办法]
hWnd
[in] Handle to a scroll bar control or a window with a standard scroll bar, depending on the value of the nBar parameter.
nBar
[in] Specifies the scroll bar to be set. This parameter can be one of the following values.
SB_CTL
Sets the range of a scroll bar control. The hwnd parameter must be the handle to the scroll bar control.
SB_HORZ
Sets the range of a window's standard horizontal scroll bar.
SB_VERT

因为你这个句柄已经是滚动条句柄了,所以就不需要再指定是horz还是vert类型了,但如果你的句柄是一个有滚动条属性的对话框或者控件,那就要指定滚动条类型了

读书人网 >VC/MFC

热点推荐