Есть, например, 200 кнопок (обычная и radiobutton).
button[i]= CreateWindow(
TEXT("BUTTON"), // Predefined class; Unicode assumed
strBtn, // Button text
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles
10, // x position
ypos, // y position
120, // Button width
30, // Button height
hWnd, // Parent window
HMENU(i), // No menu.
hInst,
NULL);
radiobutton[i] = CreateWindow(
TEXT("BUTTON"), // Predefined class; Unicode assumed
strBtn, // Button text
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON, // Styles
160, // x position
ypos, // y position
110, // Button width
30, // Button height
hWnd, // Parent window
HMENU(i), // No menu.
hInst,
NULL);
В WM_COMMAND я хочу сделать следующее - если нажать на i-тую обычную кнопку, то вместе с ней нажимается i-ая radiobutton, а предыдущие отжимаются. И наоборот, если нажать на i-ую радиокнопку, нажимается и i-ая обычная кнопка. Но у меня работает коряво, видимо не определяю какая кнопка нажата?
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
default:
{
for (int i = 0; i < BUTTONCOUNT; i++)
{
Button_SetCheck(radiobutton[i], BST_UNCHECKED);
Button_SetState(button[i], FALSE);
}
Button_SetCheck(radiobutton[LOWORD(wParam)], BST_CHECKED);
Button_SetState(button[LOWORD(wParam)], TRUE);
}
}//коряво
break;
}
Сборка персонального компьютера от Artline: умный выбор для современных пользователей