]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't enable scrollbar if it can't do anything in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 20 Jun 2010 17:42:56 +0000 (17:42 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 20 Jun 2010 17:42:56 +0000 (17:42 +0000)
Only reenable scrollbar in wxWindow::SetScrollbar() in wxMSW if its range is
large enough to allow scrolling it.

Closes #11373.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64647 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/window.cpp

index 4767df40887ff6c02d041d6ce7fae6a3c0dfc3a0..bc0a9ae9dcacd1277c3153d0d7d9a4013dcf3d66 100644 (file)
@@ -1076,10 +1076,14 @@ void wxWindowMSW::SetScrollbar(int orient,
         info.nMax = range - 1;      //  as both nMax and nMax are inclusive
         info.nPos = pos;
 
-        // enable the scrollbar if it had been disabled before by specifying
-        // SIF_DISABLENOSCROLL below: as we can't know whether this had been
-        // done or not just do it always
-        ::EnableScrollBar(hwnd, WXOrientToSB(orient), ESB_ENABLE_BOTH);
+        // We normally also reenable scrollbar in case it had been previously
+        // disabled by specifying SIF_DISABLENOSCROLL below but we should only
+        // do this if it has valid range, otherwise it would be enabled but not
+        // do anything.
+        if ( range >= pageSize )
+        {
+            ::EnableScrollBar(hwnd, WXOrientToSB(orient), ESB_ENABLE_BOTH);
+        }
     }
     //else: leave all the fields to be 0