Note that so far, the scrollbar is accessible only with the mouse. Our next step is to add keyboard access to the scrollbar. Fortunately, this is not all that difficult. We merely map some keystrokes to equivalent scrollbar actions.

void OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
{
    if (fDown) {
        switch (vk) {
        case VK_UP:         ScrollDelta(hwnd, -cRepeat); break;
        case VK_DOWN:       ScrollDelta(hwnd, +cRepeat); break;
        case VK_PRIOR:      ScrollDelta(hwnd, -cRepeat*g_cyPage); break;
        case VK_NEXT:       ScrollDelta(hwnd, +cRepeat*g_cyPage); break;
        case VK_HOME:       ScrollTo(hwnd, 0); break;
        case VK_END:        ScrollTo(hwnd, MAXLONG); break;
        }
    }
}

    /* Add to WndProc */
    HANDLE_MSG(hwnd, WM_KEYDOWN, OnKey);

Note that this doesn't make our sample program fully accessible; this just makes the scrollbars accessible. Full accessibility will be covered in a (much) later blog entry. Right now, I'm just focusing on scrollbars.