How to: Obtain a Handle to a Soft Key Menu

As shown in the following procedure, you can use either of two user interface messages to obtain a handle to a soft key menu.

To obtain a handle to a soft key menu

  • Use the SHCMBM_GETSUBMENU message. In the following example, a handle to the menu associated with the right soft key is returned.

    // IDM_CARDVIEW_SK2_MENU is the soft key's resource ID.
    hmenu = (HMENU)SendMessage(hwndMenuBar, SHCMBM_GETSUBMENU, 0,
                               IDM_CARDVIEW_SK2_MENU); 
    
  • Use the Windows CE WM_INITMENUPOPUP message, which is sent when a menu is about to be displayed.

A handle to the soft key bar's menu can be obtained by sending it the SHCMBM_GETMENU message. In the following example, a handle to the IDR_MAIN_MENU menu will be returned.

HMENU hmenu = (HMENU)SendMessage(hwndMenuBar, SHCMBM_GETMENU, 0, 0);

See Also

How to: Create a Soft Key Bar

Soft Key Overview

Last updated on Friday, April 22, 2005

© 2005 Microsoft Corporation. All rights reserved.

Send feedback on this topic to the authors.