This function enables or disables individual soft keys by command identifier or index.


Beginning with Windows Mobile 6.5.3, soft keys are replaced by touchable tiles on Windows Mobile Professional phones.


HRESULT SHEnableSoftkey(
  HWND hwndMenuBar,
  UINT uid,
  BOOL bByIndex,
  BOOL bEnable


  • hwndMenuBar
    [in] Handle to the soft key bar as returned from SHCreateMenuBar**.
  • uid
    The command identifier of the soft key or the index (0 or 1). If a soft key, then 0 indicates SK1 and 1 indicates SK2.
  • bByIndex
    Set to TRUE if the uid parameter is an index, FALSE if it is a command identifier.
  • bEnable
    Set to TRUE to enable the soft key, FALSE to disable it.

Return Value

S_OK indicates success; otherwise, returns a failure code.

Code Example

The following code example demonstrates how to use SHEnableSoftkey.


To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

#include <aygshell.h>
HWND g_hwndMb;

LRESULT CALLBACK SHCreateMenuBarWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    bool bSKEnabled = TB_ISBUTTONENABLED(1);
        case WM_KEYDOWN:
            // When the user presses the space key, toggle between enabling and disabling SK2.
            if (VK_SPACE == wParam)
                    SHEnableSoftkey(g_hwndMb, 1, TRUE, FALSE);
                    SHEnableSoftkey(g_hwndMb, 1, TRUE, TRUE);
    return DefWindowProc(hwnd, message, wParam, lParam);


Header aygshell.h
Library aygshell.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also


Shell Functions


Customizing Default Values for Soft Keys on the Home Screen

Other Resources

Soft Key and Menu Guidelines