Tuesday, August 24, 2010

2. Why an UpdateData function has to be called before checking value of controls?

The MFC's UpdateData is used in conjunction with the DoDataExchange mapping, this kind of mapping is binding a control with a data member. The UpdateData(TRUE) call is used to copy the mapped control/s properties into their data members (i.e. an Edit control's text buffer into the mapped CString data member). The UpdateData(FALSE) is doing the opposite, it copies data member/s value to their mapped control/s (i.e. if a mapped CString data member holds the ';Hello'; value, after the last call, the mapped Edit control will also display this ';hello'; value). So, before accessing any of the mapped data members, they need to be in sync with the relevant data that the controls are holding most recently, calling the UpdateData(TRUE) will accomplish this exact task for you.





S.B.
  • sunscreen
  • No comments:

    Post a Comment