ClassWizard member variables.

I have a simple application based on the document/view "paradigm" with the CFormView base view class. I draw little checks and stuff and assign member variables to them. Eg. I'll put in a checkbox and assign it a BOOL m_CheckBox variable through ClassWizard. Now, in this same dialog I have a button that I want to be enabled/disabled depending on whether or not the box is checked. Apparently I can't just say m_button.EnableWindow(m_CheckBox) without first doing a call to UpdateData()... is this how it's supposed to be? And on a side question... does UpdateData() update -all- DDX variables for the particular dialog?

In terms of style and efficiency... what's better? Making a call to UpdateData() everytime I receive a message from the checkbox saying it's been clicked and using the BOOL m_CheckBox variable I created or creating a CButton m_CheckBox control variable that I can tinker with to get the value...

OnCheckBoxClicked(?)
{
UpdateData();
m_ButtonCtrl.EnableWindow(m_CheckBoxVar);
}

or

OnCheckBoxClicked(?)
{
m_ButtonCtrl.EnableWindow(m_CheckBoxCtrl.GetState() & 3);
}

Which one is "correct"? That "& 3" is in there to mask of the state to see if it's clicked or not... Thanks!
jguerinAsked:
Who is Participating?
 
naveenkohliConnect With a Mentor Commented:
Using the first appraoch will make sure that m_CheckBoxVar data is updated everytime. But this will make all the data of your form also updated which you may not be interested in at this stage.

Therefore you may want to go with second option. That willavoid the overhead of updating all control variables.
0
All Courses

From novice to tech pro — start learning today.