difference between value and control in vc++ 6.0

Hi,

what is difference between value and control it comes under category  drop down box(Adding a Member Variable )
give me an example of a scenario for  both using  vc++ 6.0
FYI
prashanth agsoftware engineer Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ThommyCommented:
The drop down box item "Control" is for member variables that manage the control itself.
The option "Value" is only available for control types, which contain values like edit or list boxes.
If you select "Value" you can set ranges for your member variable.

Check below Microsoft url to get a deeper look into the Add Member Variable Wizard...
Add Member Variable Wizard
0
sarabandeCommented:
to add to above comment.

if you choose 'control' you will get a member CEdit, CStatic, CListBox, ... which are all derived from CWnd baseclass. the wizard will add a line with DDX_Control(...) to the DoDataExchange function.  the function call will attach the member to the window created for the control when the dialog resource was loaded.

with a control member you could call member functions of the control class directly rather than using a generic functionality:

with CEdit member m_myEdit:

void MyDialog::OnButtonClicked(..)
{
      ...
      CString strVal;
      m_myEdit.GetWindowText(strVal);  // get value from screen
      strVal += "Add More Text ....";
      int maxText = m_myEdit.GetLimitText();
      if (strVal.GetLength() > maxText)
           strVal.GetBufferSetLength(maxText);
      m_myEdit.SetWindowText(strVal);

Open in new window

     
without CEdit member

void MyDialog::OnButtonClicked(..)
{
      ...
      CString strVal;
      CEdit * pmyEdit = (CEdit*)GetDlgItem(IDC_MY_EDIT);
      if (pmyEdit != NULL)
      {
          pmyEdit.>GetWindowText(strVal);  // get value from screen
          strVal += "Add More Text ....";
          int maxText = pmyEdit->GetLimitText();
          if (strVal.GetLength() > maxText)
              strVal.GetBufferSetLength(maxText);
         pmyEdit->SetWindowText(strVal);
         ...

Open in new window


you see the difference is not much but the member avoids pointers and in the sample code an explicit cast from CWnd* to CEdit*.

The option "Value" is only available for control types, which contain values like edit or list boxes.
a CListBox has no value like all other container controls. so the 'Value' entry is only available for CCheckBox, CEdit, CComboBox, radio button,  CStatic (with ID different from IDC_STATIC), and some extended controls (for example CRichEditCtrl or CComboBoxEx)

for check button you normally would use bool type. for radio buttons you would add an int member for the first radio button only and the int would tell which radio button was selected. for all other a CString member makes most sense since any type like int or  double would not allow to have an empty value.

if using value members you could fill the defaults into the members in OnInitDialog and call UpdateData(FALSE); to show them on screen. if you want to get the (edited) values from screen you would call UpdateData(TRUE); and all members are updated by this.

note, you could have both control members and value members.

Sara
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.