假设滚动条的范围都是0到100;
void CXTabView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int nPrevPos = GetScrollPos(SB_HORZ);
switch(nSBCode)
{
case SB_LEFT: // Scroll to far left.
nPrevPos = 0;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINELEFT: // Scroll left.
nPrevPos -= 1;
break;
case SB_LINERIGHT: // Scroll right.
nPrevPos += 1;
break;
case SB_PAGELEFT: // Scroll one page left.
nPrevPos -= 10;
break;
case SB_PAGERIGHT: // Scroll one page right.
nPrevPos += 10;
break;
case SB_RIGHT: // Scroll to far right.
nPrevPos = 100;
break;
case SB_THUMBPOSITION: // Scroll to absolute position. The current position is specified by the nPos parameter.
nPrevPos = nPos;
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. The current position is specified by the nPos parameter.
nPrevPos = nPos;
break;
default :
break;
}
void CXTabView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int nPrevPos = GetScrollPos(SB_VERT);
switch(nSBCode)
{
case SB_BOTTOM: // Scroll to bottom.
nPrevPos = 100;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINEDOWN: // Scroll one line down.
nPrevPos += 1;
break;
case SB_LINEUP: // Scroll one line up.
nPrevPos -= 1;
break;
case SB_PAGEDOWN: // Scroll one page down.
nPrevPos += 10;
break;
case SB_PAGEUP: // Scroll one page up.
nPrevPos -= 10;
break;
case SB_THUMBPOSITION: // Scroll to the absolute position. The current position is provided in nPos.
nPrevPos = nPos;
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. The current position is provided in nPos.
nPrevPos = nPos;
break;
case SB_TOP: // Scroll to top.
nPrevPos = 0;
break;
default:
break;
}