Hi,
I have a dialog that contains a group of 3 radio buttons. When the user taps
on a radio button, under certain conditions, I want to disallow the change of
this setting. In my handler, I am doing this:
case BUTTON1:
if (change_allowed())
do_additional_processing();
else {
CheckRadioButton(hwnd, BUTTON1, BUTTON3, BUTTON1 + original_value);
MessageBox(show error that this change is not allowed);
}
break;
Running this code, if I tap on BUTTON1, and change_allowed returns false, I
get into an infinite loop. The error message is displayed, I tap on OK, but
the BUTTON1 handler gets called again, the error message is displayed again,
etc.
If I do the call to MessageBox before the call to CheckRadioButton, things
seem to work correctly. The error message is displayed, I tap on OK, and it
goes away. But if I then do something else that displays another dialog
(e.g., my application's About dialog), when I return to the original screen,
my error message is displayed again! For some reason, the system is sending a
WM_COMMAND for BUTTON1 upon return from the other dialog.
It doesn't seem to make any difference if I return 0 or 1 from the BUTTON1
handler. It also doesn't seem to help if I check or uncheck the Auto property
for the buttons. I'm using EVC4 in case it matters.
Can someone please tell me what I'm doing wrong? How can I show an error
message and then set the radio button selection back to the original value?
(I don't want to just disable the button, because I want the user to be able
to tap on it and get a meaningful error message.)
Thanks!
E.D.