SHEnableSoftkey

Windows Mobile 6.5
4/8/2010

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

Bb416411.note(en-us,MSDN.10).gifNote:
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.

S_OK indicates success; otherwise, returns a failure code.

The following code example demonstrates how to use SHEnableSoftkey.

Bb416411.note(en-us,MSDN.10).gifNote:
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);
    
    switch(message)
    {
        case WM_KEYDOWN:
        {
            // When the user presses the space key, toggle between enabling and disabling SK2.
            if (VK_SPACE == wParam)
            {
                if(bSKEnabled)
                {
                    SHEnableSoftkey(g_hwndMb, 1, TRUE, FALSE);
                }
                else
                {
                    SHEnableSoftkey(g_hwndMb, 1, TRUE, TRUE);
                }
            }
            break;
        }
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}

Headeraygshell.h
Libraryaygshell.lib
Windows Embedded CEWindows CE 3.0 and later
Windows MobilePocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

Community Additions

Show: