Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.


Called by the framework when the user views an area beyond the present view of the document, either by dragging an OLE item against the view's current borders or by manipulating the vertical or horizontal scrollbars.

virtual BOOL OnScrollBy(
   CSize sizeScroll,
   BOOL bDoScroll = TRUE 



Number of pixels scrolled horizontally and vertically.


Determines whether scrolling of the view occurs. If TRUE, then scrolling takes place; if FALSE, then scrolling does not occur.

Nonzero if the view was able to be scrolled; otherwise 0.

In derived classes this method checks to see whether the view is scrollable in the direction the user requested and then updates the new region if necessary. This function is automatically called by CWnd::OnHScroll and CWnd::OnVScroll to perform the actual scrolling request.

The default implementation of this method does not change the view, but if it is not called, the view will not scroll in a CScrollView-derived class.

If the document width or height exceeds 32767 pixels, scrolling past 32767 will fail because OnScrollBy is called with an invalid sizeScroll argument.

Community Additions

© 2015 Microsoft