Jump to content

WinIsMenuItemChecked

From EDM2
Revision as of 14:16, 9 April 2025 by Martini (talk | contribs) (Created page with "This function returns the state (checked/not checked) of the identified menu item. ==Syntax==  WinIsMenuItemChecked(hwndMenu, usId) ==Parameters== ;hwndMenu (HWND) - Input : Menu window handle. ;usId (USHORT) - Input : Identity of the menu item. ==Returns== ;rc (BOOL) - returns :Checked-state indicator. :;TRUE ::Menu item is checked. :;FALSE ::Menu item is not checked. ==Remarks== This macro expands to&colon. <Pre> #define WinIsMenuItemChecked(hwndMenu,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function returns the state (checked/not checked) of the identified menu item.

Syntax

 WinIsMenuItemChecked(hwndMenu, usId)

Parameters

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

Returns

rc (BOOL) - returns
Checked-state indicator.
TRUE
Menu item is checked.
FALSE
Menu item is not checked.

Remarks

This macro expands to&colon.

#define WinIsMenuItemChecked(hwndMenu, usId)
  ((BOOL)WinSendMsg(hwndMenu,
                    MM_QUERYITEMATTR,
                    MPFROM2SHORT(usId, TRUE),
                    MPFROM2SHORT(MIA_CHECKED)))

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;      /*  Checked-state indicator. */

rc = WinIsMenuItemChecked(hwndMenu, usId);

This example uses WinIsMenuItemChecked to query the check attribute of a selected menu item before setting the check state of that menu item.

#define INCL_WINWINDOWMGR   /* Window Manager Functions   */
#include <os2.h>

USHORT  usItemId;           /* Menu item ID               */
HWND    hwndMenu;           /* Menu handle                */
BOOL    usChkstate;         /* New checked state          */
BOOL    fSuccess;           /* Success indicator          */
MPARAM  mp1;                /* Parameter 1 (menu item ID) */
MPARAM  mp2;                /* Parameter 2 (menu handle)  */

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

     /* Query the current check state */
     usChkstate = WinIsMenuItemChecked(hwndMenu, usItemId);

     /* Set the menu item check state */
     fSuccess = WinCheckMenuItem(hwndMenu, usItemId, usChkstate);

Related Messages

Related Functions