Home | Overview | How Do I | Sample | Tutorial
MFC supports views that scroll and views that are automatically scaled to the size of the frame window that displays them. Class CScrollView supports both kinds of views.
For more information about scrolling and scaling, see class CScrollView in the Class Library Reference. For a scrolling example, see Enhancing Views, in Tutorials.
Frequently the size of a document is greater than the size its view can display. This may occur because the document's data increases or the user shrinks the window that frames the view. In such cases, the view must support scrolling.
Any view can handle scroll-bar messages in its OnHScroll and OnVScroll member functions. You can either implement scroll-bar message handling in these functions, doing all the work yourself, or you can use the CScrollView class to handle scrolling for you.
CScrollView does the following:
You can specify how much to scroll for a "page" (when the user clicks in a scroll-bar shaft) and a "line" (when the user clicks in a scroll arrow). Plan these values to suit the nature of your view. For example, you might want to scroll in 1-pixel increments for a graphics view but in increments based on the line height in text documents.
When you want the view to automatically fit the size of its frame window, you can use CScrollView for scaling instead of scrolling. The logical view is stretched or shrunk to fit the window's client area exactly. A scaled view has no scroll bars.