Dodataexchange, updatedata

Source: Internet
Author: User

Msdn describes this function as follows: called by the Framework to exchange and validate dialog data. The Framework calls this function to rewrite and confirm the data in the dialog box.
I don't understand what this sentence means.

After reading the DDX function in the dodataexchange function, it seems that you understand the role of the dodataexchange function. The effect of reading books recently is obvious.

In my understanding, the dodataexchange function is actually a dynamic data binding technology. For example, how do you add a variable to a button when you need to add a variable to the button during the write dynamic button process? The control class has been written, and its variables are fixed. You need to use the dodataexchange function to add new variables.

Therefore, you need to initialize a variable in the constructor of the dialog box and bind it to your Dynamic Button using the dodataexchange function, such as ddx_check (PDX, idc_check1, m_lesson1 ); this is to bind m_lesson1 (an external variable defined in the constructor of the dialog box) to idc_check1.

Take a look at the ddx_check function prototype: void afxapi ddx_check (cdataexchange * PDX, int NIDC, Int & value); you can see that m_lesson is not actually added to the idc_check1 control, note that this is Int & value, but it is only a value reference. This variable is almost passed to the control by the framework. The control is only responsible for using this variable, but not for rewriting this variable. -.-

Haha, I finally understood the meaning of the msdn sentence. Originally, the dodataexchange function was used by the framework and controls to exchange data. The DDX function is the dynamic binding technology.

It is worth noting that the Never call this function directly is appended to msdn. it is called by the updatedata member function. call updatedata to initialize a dialog box's controls or retrieve data from a dialog box. that is to say, this function is never called directly. It is called only when the updatedata function is called. (Because it needs to be re-bound every time it is updated. Is that true ?)

In short, this function is useful for understanding the MFC framework. It is also useful for writing controls.
Good good study, day up .....

The updatadata function calls dodataexchange internally. This function has only one Boolean parameter, which determines the direction of data transmission. Call updatedata (true) to transfer data from the control in the dialog box to the corresponding data member. Call updatedata (false) to send the data from the data member to the corresponding control.

Updatedata (false) uploads the value of the variable to the control.
Updatedata (true) is the variable from the control value to the associated variable

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.