How to set default radio button in MFC
-
-
I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav
I think you should do all this in OnInitDialog() in place of OnCreate. Jitendra.
-
I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav
1.) CButton* pRadio = (CButton*)GetDlgItem(ID_OF_RADIO_BUTTON); radioState = pRadio->SetCheck(1); 2.) CButton m_RadioButton; //Declare in .h file int m_bRadio; //In Constructor m_bRadio = 1; //Write in DoDataExchange function DDX_Control(pDX, ID_OF_RADIO_BUTTON, m_RadioButton); DDX_Radio(pDX, ID_OF_RADIO_BUTTON, m_bRadio); http://www.priyank.in/
-
I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav
Vaclav wrote: ...in OnCreate. Why not
OnInitialUpdate()
?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
-
I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav
Thanks for all the suggestions. Here is an update on my problem: 1. OnInitUpdate does not get executed. Don't know why. 2. If I do this, CButton* pRadio = (CButton*)GetDlgItem(ID_OF_RADIO_BUTTON); radioState = pRadio->SetCheck(1); and put in in OnCreate I 'll get assertion failure because the m_hWnd is still null at that point of program execution. I think that is the root of my problem - no m_hWnd. The above code seems to duplicate variable CButton already defined in the accompanining dialog resource anyway. Do I understand it correctly that you have used two variables associted with CButton - the control itself and than the state? PS The following code as is cannot work because SetCheck "returns" void. radioState = pRadio->SetCheck(1); Vaclav
-
I think you should do all this in OnInitDialog() in place of OnCreate. Jitendra.
-
I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav