/////////////////////////////////////////////////////////////////////////////// // UpdateThumbPosition void CXScrollBar::UpdateThumbPosition() { double dPixels, dMax, dInterval, dPos; dMax = m_nRange; dPos = m_nPos; if (m_bHorizontal) { dPixels = m_rectClient.Width() - 3*m_nBitmapWidth; dInterval = dPixels / dMax; double dThumbLeft = dPos * dInterval + 0.5; m_nThumbLeft = m_nBitmapWidth + (int)dThumbLeft; } else { dPixels = m_rectClient.Height() - 3*m_nBitmapHeight; dInterval = dPixels / dMax; double dThumbTop = dPos * dInterval + 0.5; m_nThumbTop = m_nBitmapHeight + (int)dThumbTop; } LimitThumbPosition(); Draw(); }
/////////////////////////////////////////////////////////////////////////////// // SetPositionFromThumb void CXScrollBar::SetPositionFromThumb() { double dPixels, dMax, dInterval, dPos; LimitThumbPosition(); dMax = m_nRange; if (m_bHorizontal) { dPixels = m_rectClient.Width() - 3*m_nBitmapWidth; dInterval = dMax / dPixels; dPos = dInterval * (m_nThumbLeft - m_nBitmapWidth); } else { dPixels = m_rectClient.Height() - 3*m_nBitmapHeight; dInterval = dMax / dPixels; dPos = dInterval * (m_nThumbTop - m_nBitmapHeight); } m_nPos = (int) (dPos + 0.5); if (m_nPos < 0) { m_nPos = 0; } if (m_nPos > m_nRange) { m_nPos = m_nRange; } }
void CSkinHorizontalScrollbar::UpdateThumbPosition() { #ifndef _DONT_USE_CUSTOMSCROLLBAR_ CRect clientRect; GetClientRect(&clientRect); /* CRect itemRT; pList->GetItemRect(0, itemRT, LVIR_BOUNDS); if ( clientRect.Height() < itemRT.Height() * pList->GetItemCount() ) ShowWindow(SW_SHOW); else {ShowWindow(SW_HIDE); return;} */ double nPos = pList->GetScrollPos(SB_HORZ); double nMax = pList->GetScrollLimit(SB_HORZ); double nWidth = clientRect.Width()-75; double nVar = nMax; dbThumbInterval = nWidth/nVar; double nNewdbValue = dbThumbInterval * (nPos); int nNewValue = (int)nNewdbValue; double nExtra = nNewdbValue - nNewValue; dbThumbRemainder = nExtra; nThumbLeft = 25+nNewValue; LimitThumbPosition(); Draw(); #endif }
void CSkinVerticleScrollbar::OnMouseMove(UINT nFlags, CPoint point) { CRect clientRect; GetClientRect(&clientRect); if(bMouseDown) { nThumbTop = point.y-13; //-13 so mouse is in middle of thumb double nMax = pList->GetScrollLimit(SB_VERT); int nPos = pList->GetScrollPos(SB_VERT); double nHeight = clientRect.Height()-98; double nVar = nMax; dbThumbInterval = nHeight/nVar; //figure out how many times to scroll total from top //then minus the current position from it int nScrollTimes = (int)((nThumbTop-36)/dbThumbInterval)-nPos; //grab the row height dynamically //so if the font size or type changes //our scroll will still work properly CRect itemrect; pList->GetItemRect(0,&itemrect, LVIR_BOUNDS); CSize size; size.cx = 0; size.cy = nScrollTimes*itemrect.Height(); pList->Scroll(size); LimitThumbPosition(); Draw(); } CStatic::OnMouseMove(nFlags, point); }
void CSkinVerticleScrollbar::UpdateThumbPosition() { CRect clientRect; GetClientRect(&clientRect); double nPos = pList->GetScrollPos(SB_VERT); double nMax = pList->GetScrollLimit(SB_VERT); double nHeight = (clientRect.Height()-98); double nVar = nMax; dbThumbInterval = nHeight/nVar; double nNewdbValue = (dbThumbInterval * nPos); int nNewValue = (int)nNewdbValue; nThumbTop = 36+nNewValue; LimitThumbPosition(); Draw(); }
void CSkinHorizontalScrollbar::OnMouseMove(UINT nFlags, CPoint point) { CRect clientRect; GetClientRect(&clientRect); if(bMouseDown) bDragging = true; if(bDragging) { nThumbLeft = point.x-13; //-13 so mouse is in middle of thumb double nMax = pList->GetScrollLimit(SB_HORZ); int nPos = pList->GetScrollPos(SB_HORZ); double nWidth = clientRect.Width()-75; double nVar = nMax; dbThumbInterval = nWidth/nVar; //figure out how many times to scroll total from top //then minus the current position from it int nScrollTimes = (int)((nThumbLeft-25)/dbThumbInterval)-nPos; CSize size; size.cx = nScrollTimes; size.cy = 0; pList->Scroll(size); LimitThumbPosition(); Draw(); } CStatic::OnMouseMove(nFlags, point); }