45.1.5 Keyboard Interface for a Scroll Bar

A scroll bar control provides a built-in keyboard interface that allows the user to issue scrolling requests by using the keyboard. When a scroll bar control has the keyboard focus, the control sends WM_HSCROLL and WM_VSCROLL messages to its parent window when the user presses the direction keys. The notification code that is sent with each message corresponds to the direction key that the user pressed. The following table shows the direction keys and the corresponding notification codes:

Key Notification code

UP SB_LINEUP or SB_LINELEFT
LEFT SB_LINEUP or SB_LINELEFT
DOWN SB_LINEDOWN or SB_LINERIGHT
RIGHT SB_LINEDOWN or SB_LINERIGHT
PGUP SB_PAGEUP or SB_PAGELEFT
PGDN SB_PAGEDOWN or SB_PAGERIGHT
HOME SB_TOP
END SB_BOTTOM

Notice that the keyboard interface of a scroll bar control sends the following notification codes in addition to those specified in Section 0.1.4, “Scroll Bar Requests”:

Notification Code Description

SB_TOP Scroll the window contents downward so that the top of the data object is visible.
SB_BOTTOM Scroll the window contents upward so that the bottom of the data object is visible.

If you need a keyboard interface for a standard scroll bar, you can create one yourself. This involves processing the WM_KEYDOWN message in your window procedure and performing the appropriate scrolling action based on the virtual-key code that accompanies the message. For information about how to create a keyboard interface for a scroll bar, see Section 0.2.4, “Creating a Keyboard Interface for a Standard Scroll Bar.”