Compartilhar via


SHEnableSoftkey

4/8/2010

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

Note

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

Syntax

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

Parameters

  • 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.

Note

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);
}

Requirements

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

Reference

Shell Functions

Concepts

Customizing Default Values for Soft Keys on the Home Screen

Other Resources

Soft Key and Menu Guidelines