How to Override the Back Key for Dialog Boxes with Edit Controls

Windows Mobile 6.5
4/19/2010

To override the Back key, you use the SHCMBM_OVERRIDEKEY message, the SHMENUBARINFO structure, and the SHSendBackToFocusWindow function.

  1. To override, during the handling of the Windows Embedded CE WM_INITDIALOG message, send the SHCMBM_OVERRIDEKEY message to the menu bar specified in the SHMENUBARINFO structure as follows:

    SHMENUBARINFO mbi;
    LPARAM lparam = MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
                               SHMBOF_NODEFAULT | SHMBOF_NOTIFY);
    lr = SendMessage(mbi.hwndMB, , VK_TBACK, lparam);
    // lr now contains the previous value of the key override bits.
    
  2. To send the Back key to the control with focus, call the SHSendBackToFocusWindow function during the handling of the Windows Embedded CE WM_HOTKEY message as follows:

    case WM_HOTKEY:
    {
        if(HIWORD(lParam) == VK_TBACK)
            (uMessage, wParam, lParam);
    }
    

Community Additions

Show: