Date: | August 5, 2003 / year-entry #13 |
Tags: | code |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20030805-00/?p=42983 |
Comments: | 3 |
Summary: | 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... |
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. |
Comments (3)
Comments are closed. |
Did you declare g_cyPage? (Maybe I missed it.)
Raymond,
Ive just started going through this Scrollbar tutorial (excellent by the way!), but I can not see where you declare (or set) g_cyPage that is used in this and subsequent lessons.
Oops, g_cyPage should be g_cLinesPerPage.