Jump to content

WinEnableMenuItem

From EDM2

This macro sets the state of the specified menu item to the enable flag.

Syntax

 WinEnableMenuItem(hwndMenu, usId, fEnable)

Parameters

hwndMenu (HWND) - Input
Menu window handle.
usId (USHORT) - Input
Item identifier.
fEnable (BOOL) - Input
Enable flag.

Returns

rc (BOOL) - returns
Success indicator.
TRUE
Successful completion
FALSE
Error occurred.

Remarks

This macro expands to&colon.

#define WinEnableMenuItem(hwndMenu, usId, fEnable)
((BOOL)WinSendMsg(hwndMenu,
                  MM_SETITEMATTR,
                  MPFROM2SHORT(usId, TRUE),
                  MPFROM2SHORT(MIA_DISABLED, (BOOL)(fEnable) ? 0 : MIA_DISABLED)))

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;      /*  Item identifier. */
BOOL    fEnable;  /*  Enable flag. */
BOOL    rc;       /*  Success indicator. */

rc = WinEnableMenuItem(hwndMenu, usId, fEnable);

This example uses WinEnableMenuItem to make a menu item selection available when the menu is initialized (WM_INITMENU).

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

BOOL    fResult;        /* message-posted indicator             */
MPARAM  mpParam1;       /* Parameter 1 (rectl structure)        */
MPARAM  mpParam2;       /* Parameter 2 (frame boolean)          */
USHORT  usItemId;       /* menu item id                         */
HWND    hwndMenu;       /* menu handle                          */

case WM_INITMENU:
     usItemId = SHORT1FROMMP(mpParam1);
     hwndMenu = HWNDFROMMP(mpParam2);

     /* enable menu item */
     fResult = WinEnableMenuItem(hwndMenu, usItemId, TRUE);

Related Messages

Related Functions