From: Vadim Zeitlin Date: Sun, 28 Feb 2010 11:30:55 +0000 (+0000) Subject: Simplify and correct bugs in wxMSW wxScrollBar message handling. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/57a4b972cfbf432ad3c3e9f442a7b42ea6d48ade Simplify and correct bugs in wxMSW wxScrollBar message handling. For some reason we computed scroll increment from the native message and not the new position directly which is actually simpler and probably would have never resulted in a bug which exchanged the meanings of SB_TOP and SB_BOTTOM. Get rid of nScrollInc and just update the position variable directly. Closes #11741. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63587 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/scrolbar.cpp b/src/msw/scrolbar.cpp index 54a5cf7e27..f45e294396 100644 --- a/src/msw/scrolbar.cpp +++ b/src/msw/scrolbar.cpp @@ -119,7 +119,6 @@ bool wxScrollBar::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam, return false; } - int position = scrollInfo.nPos; int maxPos = scrollInfo.nMax; // A page size greater than one has the effect of reducing the effective @@ -128,61 +127,54 @@ bool wxScrollBar::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam, if ( m_pageSize > 1 ) maxPos -= (m_pageSize - 1); + int position = scrollInfo.nPos; wxEventType scrollEvent = wxEVT_NULL; - - int nScrollInc; switch ( wParam ) { case SB_TOP: - nScrollInc = maxPos - position; + position = 0; scrollEvent = wxEVT_SCROLL_TOP; break; case SB_BOTTOM: - nScrollInc = -position; + position = maxPos; scrollEvent = wxEVT_SCROLL_BOTTOM; break; case SB_LINEUP: - nScrollInc = -1; + position--; scrollEvent = wxEVT_SCROLL_LINEUP; break; case SB_LINEDOWN: - nScrollInc = 1; + position++; scrollEvent = wxEVT_SCROLL_LINEDOWN; break; case SB_PAGEUP: - nScrollInc = -GetPageSize(); + position -= GetPageSize(); scrollEvent = wxEVT_SCROLL_PAGEUP; break; case SB_PAGEDOWN: - nScrollInc = GetPageSize(); + position += GetPageSize(); scrollEvent = wxEVT_SCROLL_PAGEDOWN; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: - nScrollInc = scrollInfo.nTrackPos - position; + position = scrollInfo.nTrackPos; scrollEvent = wParam == SB_THUMBPOSITION ? wxEVT_SCROLL_THUMBRELEASE : wxEVT_SCROLL_THUMBTRACK; break; case SB_ENDSCROLL: - nScrollInc = 0; scrollEvent = wxEVT_SCROLL_CHANGED; break; - - default: - nScrollInc = 0; } - if ( nScrollInc ) + if ( position != scrollInfo.nPos ) { - position += nScrollInc; - if ( position < 0 ) position = 0; if ( position > maxPos )