July 29th, 2013

A program for my nieces: The ABCs, part 4

Disabling autorepeat in my ABC program was largely sufficient to keep my nieces happy, given their instructions to press only one key at a time. Once in a while, though, they would hit the context menu key in the bottom right corner of the keyboard, and then they’d get stuck because they didn’t know how to dismiss it.

So let’s disable that key outright.

LRESULT CALLBACK EditSubclassProc(
    HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
    UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
  switch (uMsg) {
  case WM_NCDESTROY:
    RemoveWindowSubclass(hwnd, EditSubclassProc, uIdSubclass);
    break;
  case WM_CHAR:
    if ((lParam & 0x40000000) && wParam != VK_BACK) return 0;
    break;
  case WM_CONTEXTMENU:
    return 0;
  }
    return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}

Well, that was awfully anticlimactic, wasn’t it.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.