更改代码 DoEvent() MouseMove 事件时计算位置
if( (m_uThumbState & UISTATE_CAPTURED) != 0 ) {
if( !m_bHorizontal ) {
int vRange = m_rcItem.bottom - m_rcItem.top - m_rcThumb.bottom + m_rcThumb.top - 2 * m_cxyFixed.cx;
if (vRange != 0) m_nLastScrollOffset = (event.ptMouse.y - ptLastMouse.y) * (m_nRange / vRange);
}
else {
int hRange = m_rcItem.right - m_rcItem.left - m_rcThumb.right + m_rcThumb.left - 2 * m_cxyFixed.cy;
if (hRange != 0) m_nLastScrollOffset = (event.ptMouse.x - ptLastMouse.x) * (m_nRange / hRange);
}
}
SetPos 设置位置时
if( m_nRange > 0 ) {
int cyThumb = cy * (rc.bottom - rc.top) / (m_nRange + rc.bottom - rc.top);
if( cyThumb < m_cxyFixed.cx ) cyThumb = m_cxyFixed.cx;
m_rcThumb.top = (double)m_nScrollPos / m_nRange * (cy - cyThumb) + m_rcButton1.bottom;
m_rcThumb.bottom = m_rcThumb.top + cyThumb;
if( m_rcThumb.bottom > m_rcButton2.top ) {
m_rcThumb.top = m_rcButton2.top - cyThumb;
m_rcThumb.bottom = m_rcButton2.top;
}
}