If you used the CScrollView for the application then just
call following method
void CScrollBarDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int CurPos = m_ScrollBar.GetScrollPos();
switch (nSBCode)
{
case SB_LEFT:
CurPos = 0;
break;
case SB_RIGHT:
CurPos = 122;
break;
case SB_ENDSCROLL:
break;
case SB_LINELEFT:
if (CurPos > 0)
CurPos--;
break;
case SB_LINERIGHT:
if (CurPos < 122)
CurPos++;
break;
case SB_PAGELEFT:
{
SCROLLINFO info;
m_ScrollBar.GetScrollInfo(&info, SIF_ALL);
if (CurPos > 0)
CurPos = max(0, CurPos - (int) info.nPage);
}
break;
case SB_PAGERIGHT:
{
SCROLLINFO info;
m_ScrollBar.GetScrollInfo(&info, SIF_ALL);
if (CurPos < 122)
CurPos = min(122, CurPos + (int) info.nPage);
}
break;
case SB_THUMBPOSITION:
CurPos = nPos;
break;
case SB_THUMBTRACK:
CurPos = nPos;
break;
}
m_ScrollBar.SetScrollPos(CurPos);
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
m_ScrollBar.SetScrollRange(0, 122);