我使用 mingw32 编译器。我创建了两个radioButton:
radio1 = CreateWindowExW(WS_EX_TRANSPARENT , L"BUTTON", L"RadioButton1",
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON ,
0, 0, 0, 0,
hwnd, (HMENU)ID_RADIOBTN1,
GetModuleHandle(NULL), 0);
SendMessage(radioBtnDaily, WM_SETFONT, (WPARAM) font, TRUE);
radio2 = CreateWindowExW(WS_EX_TRANSPARENT , L"BUTTON", L"RadioButton2",
WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON ,
0, 0, 0, 0,
hwnd, (HMENU)ID_RADIOBTN2,
GetModuleHandle(NULL), 0);
SendMessage(radio1, BM_SETCHECK , (WPARAM) font, TRUE);
SendMessage(radio2, WM_SETFONT, (WPARAM) font, TRUE);
我处理检查状态,如下所示:
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_RADIOBTN1:
{
MessageBoxW( NULL, "radio1 is checked", L"radio", MB_OK | MB_ICONERROR );
}
break;
case ID_RADIOBTN2:
{
MessageBoxW( NULL, "radio2 is checked", L"radio", MB_OK | MB_ICONERROR );
}
break;
....
但这总是在我单击单选按钮时运行,因此它不会检查状态。如何在不使用点击事件的情况下检查状态?