How to create a radio button and see if it's checked?
- Windows Vista
- Dev-C++
- Win32 API
- WM styles
How to create a radio button and see if it's checked?
To find out whether a radio button (or check box) is checked, send the BM_GETCHECK
message to the control and check the return value. You will need the HWND
of your control; to get that from the control ID, call GetDlgItem()
.
Use CreateWindow()
or CreateWindowEx()
with the button style BS_RADIOBUTTON
or BS_AUTORADIOBUTTON
to create one. E.g.:
HWND radioButtonHandle = CreateWindow(
TEXT("BUTTON"), TEXT("my radio button"),
WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON,
/* ... */);