A program for my nieces: The ABCs, part 4

Raymond Chen

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.