This example responds to a button click (BN_CLICKED, WM_CONTROL message) on a check box by setting the checked state of the button.

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

USHORT  usCheckId;      /* check box id                         */
HWND  hwndDlg;          /* dialog window handle                 */
USHORT  usChkstate;     /* new checked state                    */
USHORT  usOldstate;     /* old checked state                    */
MPARAM  mp1;            /* Parameter 1 (rectl structure)        */
MPARAM  mp2;            /* Parameter 2 (frame boolean)          */

case WM_CONTROL:
     /* switch on control code */
     switch(SHORT2FROMMP(mp1))
        {
        case BN_CLICKED:
             usCheckId = SHORT1FROMMP(mp1);

             /* query current check state */
             usChkstate = WinQueryButtonCheckstate(hwndDlg,
                          usCheckId);

             /* set box check state */
             usOldstate = WinCheckButton(hwndDlg, usCheckId,
                                         usChkstate);
             break;
        }


[Back] [Next]