Jump to content

WinCheckMenuItem: Difference between revisions

From EDM2
Created page with "This macro sets the check state of the specified menu item to the flag. ==Syntax== WinCheckMenuItem(hwndMenu, usItemId, ! usChkstate) ==Parameters== ;hwndMenu (HWND) - inp..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
This macro sets the check state of the specified menu item to the flag.  
This macro sets the check state of the specified menu item to the flag.


==Syntax==
==Syntax==
  WinCheckMenuItem(hwndMenu, usItemId, ! usChkstate)
  WinCheckMenuItem(hwndMenu, usItemId, usChkstate)


==Parameters==
==Parameters==
;hwndMenu (HWND) - input
;hwndMenu (HWND) - input:Menu window handle.
:Menu window handle.  
;usId (USHORT) - input:Item identifier.
 
;fCheck (BOOL) - input:Check flag.
;usId (USHORT) - input
:Item identifier.  
 
;fCheck (BOOL) - input
:Check flag.


==Returns==
==Returns==
; rc (BOOL) - returns
; rc (BOOL) - returns:Success indicator.
:Success indicator.
:;TRUE:Successful completion
:;TRUE
:;FALSE:Error occurred.
::Successful completion  
:;FALSE
::Error occurred.


==Remarks==
==Remarks==
This macro expands to:
This macro expands to:
  #define WinCheckMenuItem(hwndMenu, usId, fCheck)
  #define WinCheckMenuItem(hwndMenu, usId, fCheck)
   ((BOOL)WinSendMsg(hwndMenu,
   ((BOOL)WinSendMsg(hwndMenu,
Line 30: Line 21:
                     MPFROM2SHORT(usId, TRUE),
                     MPFROM2SHORT(usId, TRUE),
                     MPFROM2SHORT(MIA_CHECKED, (BOOL)(fCheck) ? MIA_CHECKED : 0)))
                     MPFROM2SHORT(MIA_CHECKED, (BOOL)(fCheck) ? MIA_CHECKED : 0)))
This function requires the existence of a message queue.  
This function requires the existence of a message queue.  


Line 55: Line 45:
     /* set menu item check state */
     /* set menu item check state */
     fSuccess = WinCheckMenuItem(hwndMenu, usItemId, ! usChkstate);
     fSuccess = WinCheckMenuItem(hwndMenu, usItemId, ! usChkstate);
</pre>
Definition
<pre>
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>
HWND      hwndMenu;  /*  Menu window handle. */
USHORT    usId;      /*  Item identifier. */
BOOL      fCheck;    /*  Check flag. */
BOOL      rc;        /*  Success indicator. */
rc = WinCheckMenuItem(hwndMenu, usId, fCheck);
</pre>
</pre>


==Related Functions==
==Related Functions==
* WinSendMsg
* [[WinSendMsg]]


==Related Messages==
==Related Messages==

Latest revision as of 14:36, 4 October 2023

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

Syntax

WinCheckMenuItem(hwndMenu, usItemId, usChkstate)

Parameters

hwndMenu (HWND) - input
Menu window handle.
usId (USHORT) - input
Item identifier.
fCheck (BOOL) - input
Check flag.

Returns

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

Remarks

This macro expands to:

#define WinCheckMenuItem(hwndMenu, usId, fCheck)
  ((BOOL)WinSendMsg(hwndMenu,
                    MM_SETITEMATTR,
                    MPFROM2SHORT(usId, TRUE),
                    MPFROM2SHORT(MIA_CHECKED, (BOOL)(fCheck) ? MIA_CHECKED : 0)))

This function requires the existence of a message queue.

Example Code

This example responds to a select menu message (WM_MENUSELECT) by querying (via WinIsMenuItemChecked) the check attribute and then setting the check state of the menu item that was selected.

#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 current check state */
     usChkstate = WinIsMenuItemChecked(hwndMenu, usItemId);

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

Related Functions

Related Messages

  • MM_SETITEMATTR