The simplest way to scroll is to erase and then redraw the contents of the client area. This is the method an application is likely to use with SB_PAGEUP, SB_PAGEDOWN, SB_TOP, and SB_END requests, which typically require completely new contents.
For some requests, such as SB_LINEUP and SB_LINEDOWN, not all the contents need to be erased, since some will still be visible after scrolling occurs. The ScrollWindow and ScrollWindowEx functions preserve a portion of the client area's contents, move the preserved portion the specified amount, and prepare the rest of the client area for painting new information. ScrollWindow and ScrollWindowEx use the BitBlt function to move a specific part of the client area to a new location within the client area. Any part of the client area that is uncovered (not in the part to be preserved) is invalidated and will be erased and painted at the next WM_PAINT message.
ScrollWindow and ScrollWindowEx also let you exclude a portion of the client area from the scrolling operation. This is to keep items that have fixed positions in the client area, such as child windows, from moving. This action automatically invalidates the part of the client area that is to receive the new information so that your application does not have to compute its own clipping regions. For more information on clipping, see Chapter 72, “Clipping.”
Your application should scroll the contents of a window in the direction opposite that indicated by the scroll bar. For example, when the user clicks the shaft in the area below the scroll box, your application should scroll the object in the window upward to reveal a portion of the object that is below the currently visible portion. The following illustration shows the scrolling operation that your application should perform when it processes the SB_PAGEDOWN notification code: