Opened 9 years ago

Closed 9 years ago

#11741 closed defect (fixed)

Scrollbars Top and Bottom do not behave as expected

Reported by: IGOAL_William Owned by:
Priority: normal Milestone:
Component: wxMSW Version: 2.8.10
Keywords: MSW wxScrollbar wxEVT_SCROLL_TOP wxEVT_SCROLL_BOTTOM Cc:
Blocked By: Blocking:
Patch: no


I'm running a Windows2K machine, and when I right click on a scrollbar and select the "top" or "bottom" menu options, they do reverse of what I expect.

Not only that, the mechanism "to do nothing if the wxScrollbar message is received but not changes are detected" are getting in the way of overriding wxEVT_SCROLL_TOP and wxEVT_SCROLL_BOTTOM. So when I'm at the bottom, I cannot scroll to the top, and when I'm at the top I can't scroll to the bottom using these menu commands because it doesn't detect any changes in the default implementation of wxScrollBar::MSWOnScroll.

Someone pointed out to me that the MSWOnScroll function is virtual so I can override the MSW function, but it seems like the default implementation should be changed.

Change History (4)

comment:1 Changed 9 years ago by vadz

  • Milestone future deleted
  • Status changed from new to infoneeded_new

If I run the scroll sample the menu commands top and bottom seem to work just fine for me. I've only tested it under Win7 but I'm also pretty sure it worked under XP which I used until recently. Before I spend time on testing it under Win2k could you please confirm that the sample misbehaves there too? If it's just your own code which doesn't work, what is the difference between the sample and it?


P.S. I'm only answering the first problem as I didn't understand at all the two subsequent paragraphs, if they're important, please try to explain better what did you mean.

comment:2 follow-up: Changed 9 years ago by IGOAL_William

  • Status changed from infoneeded_new to new

The scrolling examples use the ScrollWindow class and not the wxScrollBar class.

In src/msw/scrollbar.cpp:

  • around line 210, the thumb position is only changed if nScrollInc is nonzero.
  • around line 162, "nScrollInc = maxPos - position;" this means if the position is at the bottom then position == maxPos and nScrollInc is zero and the thumb isn't changed, even though the scrollbar is scrolled at the bottom and I just requested it to scroll to the top.
  • The same for SB_BOTTOM, it's made so that if I'm at the top, where the thumb pos is 0 and request to go to the bottom, "nScrollInc = -position;" at line 167 makes it skip setting the thumb.

It just seems like the logic was reversed for SB_TOP and SB_BOTTOM on how to set nScrollInc. I checked scrollbar.cpp in the snapshot download and it's the same.

comment:3 in reply to: ↑ 2 Changed 9 years ago by vadz

  • Status changed from new to confirmed

Replying to IGOAL_William:

The scrolling examples use the ScrollWindow class and not the wxScrollBar class.

Sorry, it wasn't clear that you were speaking about the latter. This is why having a patch demonstrating the problem is so useful.

It just seems like the logic was reversed for SB_TOP and SB_BOTTOM on how to set nScrollInc.

Yes, indeed, I see it now. I'm going to fix this in svn (2.9) blindly, please reopen if you still have any problems.


comment:4 Changed 9 years ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [63587]) 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.

Note: See TracTickets for help on using tickets.