Compartilhar via


Receiving Keypad Presses

4/8/2010

Once the Windows Classic Home screen plug-in has the selection focus, each keypad button press causes it to receive a WM_TODAYCUSTOM_USERNAVIGATION message. If the plug-in handles the button press internally, it should return TRUE in response to this message. Otherwise, the Windows Classic Home screen passes the selection on to the next item if either the up or down key was pressed. This can be used to navigate through a series of sub-items.

WM_TODAYCUSTOM_USERNAVIGATION is defined as (WM_USER + 246). The parameter wParam is set to the virtual key code of the keypress (e.g., VK_UP, VK_LEFT, etc); lParam is not used.

The action button is handled differently. If the action button is pressed, the plug-in receives a WM_TODAYCUSTOM_ACTION message, unless the value of Selectability is equal to one, in which case it receives a WM_LBUTTONDOWN and a WM_LBUTTONUP message at coordinates (1, 1), simulating a user tap.

WM_TODAYCUSTOM_ACTION is defined as (WM_USER + 247). The parameter wParam is equal to the virtual key code for the action key (i.e., VK_RETURN); lParam is not used. The return value for this message is ignored. The following code example shows this.

case WM_TODAYCUSTOM_USERNAVIGATION:
   InvalidateRect(hwnd, NULL, FALSE);

   if (wParam == VK_UP)   g_nSelectedItem--;
   if (wParam == VK_DOWN) g_nSelectedItem++;

   if (g_nSelectedItem < 0 || g_nSelectedItem >= MAX_ITEMS)
   {
      return FALSE; // go to the next plug-in
   }
   else
   {
      return TRUE;  // stay in this plug-in
   }

case WM_TODAYCUSTOM_ACTION:
   OnAction();
   break;

See Also

Other Resources

Windows Classic Home Screen Plug-in Selection