Radio Button Query.
-
I have an MFC Dialog which houses 3 radio buttons. I want to take some action only when user selects radio button which is not selected already so that I don't perform the same set of actions if a user RE-Selects a radio button. Can someone advise me what's the best way to achieve this ? Thanks Cage
-
I have an MFC Dialog which houses 3 radio buttons. I want to take some action only when user selects radio button which is not selected already so that I don't perform the same set of actions if a user RE-Selects a radio button. Can someone advise me what's the best way to achieve this ? Thanks Cage
Hi, You mean when clicking the same radio button again and again or when selecting a button and change to other again come back to previous button? In second case, you can set a static variable like
static bool bAlreadySelected = true
when the button clicked already it will be true. Otherwise perform the set of options. Set the above variable tofalse
at startup of dialog. This is one way. There may be some other way too. Thanks, Suman-- "Programming is an art that fights back!"
modified on Friday, April 4, 2008 1:22 AM
-
Hi, You mean when clicking the same radio button again and again or when selecting a button and change to other again come back to previous button? In second case, you can set a static variable like
static bool bAlreadySelected = true
when the button clicked already it will be true. Otherwise perform the set of options. Set the above variable tofalse
at startup of dialog. This is one way. There may be some other way too. Thanks, Suman-- "Programming is an art that fights back!"
modified on Friday, April 4, 2008 1:22 AM
No Suman, that doesnt solve my problem. I want to take a certain action everytime the control is transferred from the other radio button, not just for the first time. Let me be more clear. Example - Three radio buttons be A, B and C. I want to perform certain operations everytime user has selected A or B and then he clicks C, but I don't want to take any action if user re-selects C.
-
No Suman, that doesnt solve my problem. I want to take a certain action everytime the control is transferred from the other radio button, not just for the first time. Let me be more clear. Example - Three radio buttons be A, B and C. I want to perform certain operations everytime user has selected A or B and then he clicks C, but I don't want to take any action if user re-selects C.
That's not very complicated: in your class declare an integer variable (e.g. m_currentSelected). On each of your radio button handler functions, assign a value to this variable (e.g. 1 for the first radio button, 2 for the second, ...). It is easier with code:
void CMyClass::OnRadio1Clicked()
{
if(m_currentSelected==1)
return;// Do stuff....
m_currentSelected = 1;
}Cédric Moonen Software developer
Charting control [v1.3] -
That's not very complicated: in your class declare an integer variable (e.g. m_currentSelected). On each of your radio button handler functions, assign a value to this variable (e.g. 1 for the first radio button, 2 for the second, ...). It is easier with code:
void CMyClass::OnRadio1Clicked()
{
if(m_currentSelected==1)
return;// Do stuff....
m_currentSelected = 1;
}Cédric Moonen Software developer
Charting control [v1.3]