From f074df3446a4636396d7a305eab319894df76d52 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 20 Jun 2010 17:42:56 +0000 Subject: [PATCH] Don't enable scrollbar if it can't do anything in wxMSW. 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 4767df4088..bc0a9ae9dc 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -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 -- 2.45.2