Hello, in my program written in C++ using pure Win32 I have a dialog box
with two groups of radio buttons. Under WM_INITDIALOG I check a button in
each group like this:
SendMessage(resolution_1280_1024_radio_button, BM_SETCHECK, BST_CHECKED, 0);
SendMessage(color_depth_32_radio_button, BM_SETCHECK, BST_CHECKED, 0);
After these two calls the buttons are checked as they should. But, if I ask
my program to tell me which radio buttons are checked it says no buttons are
checked unless I change the initial checks. Why? Isn't BM_SETCHECK enough?
The two function for determining the state of each group of radio buttons
looks like this:
void get_resolution(HWND resolution_1280_1024_radio_button,
HWND resolution_1024_768_radio_button,
HWND resolution_800_600_radio_button,
int* width,
int* height)
{
if(SendMessage(resolution_1280_1024_radio_button, BM_GETCHECK, 0, 0) ==
BST_CHECKED)
{
(*width) = 1280;
(*height) = 1024;
}
else if(SendMessage(resolution_1024_768_radio_button, BM_GETCHECK, 0, 0)
== BST_CHECKED)
{
(*width) = 1024;
(*height) = 768;
}
else if(SendMessage(resolution_800_600_radio_button, BM_GETCHECK, 0, 0)
== BST_CHECKED)
{
(*width) = 800;
(*height) = 600;
}
(*width) = -1;
(*height) = -1;
throw "Error in get_resolution()";
}
void get_color_depth(HWND color_depth_32_radio_button,
HWND color_depth_16_radio_button,
HWND color_depth_8_radio_button,
int* color_depth)
{
if(SendMessage(color_depth_32_radio_button, BM_GETCHECK, 0, 0) ==
BST_CHECKED)
{
(*color_depth) = 32;
}
else if(SendMessage(color_depth_16_radio_button, BM_GETCHECK, 0, 0) ==
BST_CHECKED)
{
(*color_depth) = 16;
}
else if(SendMessage(color_depth_8_radio_button, BM_GETCHECK, 0, 0) ==
BST_CHECKED)
{
(*color_depth) = 8;
}
(*color_depth) = -1;
throw "Error in get_color_depth()";
}
What am I doing wrong?
/ WP