Jump to content

WinIsMenuItemValid

From EDM2

This function indicates if the specified menu item is a valid choice.

Syntax

 WinIsMenuItemValid(hwndMenu, usId)

Parameters

hwndMenu (HWND) - Input
Menu window handle.
usId (USHORT) - Input
Identity of the menu item.

Returns

rc (BOOL) - returns
Validity indicator.
TRUE
Menu item is valid.
FALSE
Menu item is invalid.

Remarks

This macro expands to&colon.

#define WinIsMenuItemValid(hwndMenu, usId)
  ((BOOL)WinSendMsg(hwndMenu,
                    MM_ISITEMVALID,
                    MPFROM2SHORT(usId, TRUE),
                    MPFROMSHORT(FALSE)))

This function requires the existence of a message queue.

Example Code

#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HWND    hwndMenu;  /*  Menu window handle. */
USHORT  usId;      /*  Identity of the menu item. */
BOOL    rc;      /*  Validity indicator. */

rc = WinIsMenuItemValid(hwndMenu, usId);

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

Related Messages

Related Functions