OnInitialDialog
SCROLLINFO si = {0};
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE|SIF_PAGE;
si.nMin = 0;
si.nMax = 100;
si.nPage = 10;
m_scroll.SetScrollInfo(&si);
void CDemoDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
SCROLLINFO si= {0};
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
pScrollBar->GetScrollInfo(&si);
int nNewPos = si.nPos;
switch(nSBCode)
{
case SB_THUMBTRACK:
nNewPos = nPos;
break;
case SB_LINELEFT:
nNewPos -= 1;
break;
case SB_LINERIGHT:
nNewPos += 1;
break;
case SB_PAGELEFT:
nNewPos -= si.nPage;
break;
case SB_PAGERIGHT:
nNewPos += si.nPage;
break;
default:
break;
}
if(nNewPos > si.nMax)
nNewPos = si.nMax;
if(nNewPos < si.nMin)
nNewPos = si.nMin;
pScrollBar->SetScrollPos(nNewPos);
CString s;
s.Format(_T("%d"), nNewPos);
m_pos = s;
UpdateData(FALSE);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}