根据得到的窗口句柄,发送WM_VSCROLL,WM_HSCROLLSB_BOTTOM Scrolls to the lower right. SB_ENDSCROLL Ends scroll. SB_LINEDOWN Scrolls one line down. SB_LINEUP Scrolls one line up. SB_PAGEDOWN Scrolls one page down. SB_PAGEUP Scrolls one page up. SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation. SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to. SB_TOP Scrolls to the upper left.
请看滚动栏消息定义: WM_HSCROLL nScrollCode = (int) LOWORD(wParam); // scroll bar value nPos = (short int) HIWORD(wParam); // scroll box position hwndScrollBar = (HWND) lParam; 如果用父窗体默认滚动栏,则hwndScrollBar为NULL,否则是自定义的滚动栏,hwndScrollBar不为NULL, 很多程序都使用自定义的滚动栏,应此 SendMessage(hWnd,WM_HSCROLL,SB_LEFT,0)也许为引发该程序的内部的运行错误,不是安全的做法
根据得到的窗口句柄,发送WM_VSCROLL,WM_HSCROLLSB_BOTTOM Scrolls to the lower right. SB_ENDSCROLL Ends scroll. SB_LINEDOWN Scrolls one line down. SB_LINEUP Scrolls one line up. SB_PAGEDOWN Scrolls one page down. SB_PAGEUP Scrolls one page up. SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation. SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to. SB_TOP Scrolls to the upper left. 试一试
PostMessage(滚动条窗体或滚动条句柄,WM_HSCROLL/WM_VSCROLL,CSM_PAGEUP/CSM_PAGEDOWN/CSM_LINEUP.....,0);
/表示选择其一,如果为CSM_SETPOS,这wParam这一项必须为你想要的位置。
example:
SendMessage(hWnd, WM_VSCROLL,SB_PAGEDOWN,0);
参考:
http://search.csdn.net/Expert/topic/514/514868.xml?temp=1.581973E-02
SB_ENDSCROLL Ends scroll.
SB_LINEDOWN Scrolls one line down.
SB_LINEUP Scrolls one line up.
SB_PAGEDOWN Scrolls one page down.
SB_PAGEUP Scrolls one page up.
SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation.
SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to.
SB_TOP Scrolls to the upper left.
WM_HSCROLL
nScrollCode = (int) LOWORD(wParam); // scroll bar value
nPos = (short int) HIWORD(wParam); // scroll box position
hwndScrollBar = (HWND) lParam; 如果用父窗体默认滚动栏,则hwndScrollBar为NULL,否则是自定义的滚动栏,hwndScrollBar不为NULL,
很多程序都使用自定义的滚动栏,应此
SendMessage(hWnd,WM_HSCROLL,SB_LEFT,0)也许为引发该程序的内部的运行错误,不是安全的做法
^_^具体消息内容见楼上几位
SendMessage
呵呵。师父也在啊
1,如何知道哪个窗口包含滚动条?
2,SendMessage应该发送给ScrollBar还是其父窗口,还是其它?
SB_ENDSCROLL Ends scroll.
SB_LINEDOWN Scrolls one line down.
SB_LINEUP Scrolls one line up.
SB_PAGEDOWN Scrolls one page down.
SB_PAGEUP Scrolls one page up.
SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation.
SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to.
SB_TOP Scrolls to the upper left. 试一试