WinIsMenuItemEnabled
Appearance
This function returns the state (enabled/disabled) of the specified menu item.
Syntax
WinIsMenuItemEnabled(hwndMenu, usId)
Parameters
Returns
- rc (BOOL) - returns
- Enabled-state indicator.
- TRUE
- Menu item is enabled.
- FALSE
- Menu item is disabled.
Remarks
This macro expands to&colon.
#define WinIsMenuItemEnabled(hwndMenu, usId) (!(BOOL)WinSendMsg(hwndMenu, MM_QUERYITEMATTR, MPFROM2SHORT(usId, TRUE), MPFROMSHORT(MIA_DISABLED)))
This function requires the existence of a message queue. This function returns TRUE if called with an invalid window handle or menu item. The window handle and menu item should be separately validated before being passed as parameters to this function.
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; /* Enabled-state indicator. */ rc = WinIsMenuItemEnabled(hwndMenu, usId);
This example uses WinIsMenuItemEnabled to determine if a selected menu item is available for use. If the item is not valid (WinIsMenuItemValid) or not enabled, 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 not valid or enabled, emit a beep */ if (!WinIsMenuItemValid(hwndMenu, usItemId) || !WinIsMenuItemEnabled(hwndMenu, usItemId)) DosBeep(800,100L);