This example uses WinIsMenuItemValid to determine if a selected menu item is available for use. If the item is disabled (WinIsMenuItemEnabled) or invalid, a beep is emitted.

#define INCL_WINMESSAGEMGR  /* Window Message Functions      */
#define INCL_WINMENUS       /* Window Menu Functions         */
#define INCL_DOSPROCESS     /* OS/2 Process Functions        */
#include <os2.h>

MPARAM  mp1;                /* Parameter 1 (rectl structure) */
MPARAM  mp2;                /* Parameter 2 (frame boolean)   */
USHORT  usItemId;           /* Menu item ID                  */
HWND    hwndMenu;           /* Menu handle                   */

case WM_MENUSELECT:
     usItemId = SHORT1FROMMP(mp1);
     hwndMenu = HWNDFROMMP(mp2);

     /* If the menu item is invalid or disabled, emit a beep */
     if (!WinIsMenuItemValid(hwndMenu, usItemId) ||
         !WinIsMenuItemEnabled(hwndMenu, usItemId))
        DosBeep(800,100L);


[Back] [Next]