WinCheckButton: Difference between revisions
Appearance
Line 82: | Line 82: | ||
==Related Messages== | ==Related Messages== | ||
* BM_SETCHECK | * [[BM_SETCHECK]] | ||
[[Category:Win]] | [[Category:Win]] |
Latest revision as of 18:41, 14 May 2025
This macro sets the checked state of the specified button control. It returns the previous check state.
Syntax
WinCheckButton(hwndDlg, usId, usChkstate);
Parameters
- hwndDlg (HWND) - input
- Dialog window handle.
- usId (USHORT) - input
- Button control identity.
- usChkstate (USHORT) - input
- Indicates the current checked state of the button.
Returns
- usRetChkst (USHORT) - returns
- Returns the previous checkstate.
Remarks
This macro expands to:
- define WinCheckButton(hwndDlg, usId, usChkstate)
((USHORT)WinSendDlgItemMsg(hwndDlg, usId, BM_SETCHECK, MPFROMSHORT(usChkstate), (MPARAM)NULL))
This call requires the existence of a message queue.
Example Code
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; }
Definition
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwndDlg; /* Dialog window handle. */ USHORT usId; /* Button control identity. */ USHORT usChkstate; /* Indicates the current checked state of the button. */ USHORT usRetChkst; /* Returns the previous checkstate. */ usRetChkst = WinCheckButton(hwndDlg, usId, usChkstate);