Functions of MFC updatedata (false) and updatedata (true)

Source: Internet
Author: User

In VC, you can set the corresponding variables for the controls in the dialog box. For example, you can set the corresponding cstring variable in the text box, but when you modify the content of the text box in the program, the corresponding cstring variable does not change. You need to call updatedata (true) to change the variable. Similarly, the cstring variable is changed in the program. You also need to call updatedata (false) to change the content of the text box.
Other controls are similar, such as single choice, Check button status, and corresponding bool variables.

That is, false maps variables to controls, while true maps from controls to variables.

After you use classwizard to establish the connection between the control and the variable: When you modify the value of the variable, you want to update the display of the control in the dialog box, you should call updatedata (false) after modifying the variable. If you want to know what the user enters in the dialog box, you should call updatedata (true) before accessing the variable ).
1,

Updatedata (true );
Update the value of the variable associated with the control using the content in the control on the form (only variables of the value type can be updated)
For example, you have an edit control in your form that is associated with the cstring variable m_strname;
After you add content to the control, you must call updatedata (true); to pass the added content to the m_strname variable

Updatedata (false );
In contrast to the preceding example, if you change the content of the m_strname variable in the program, if you want that edit to display the updated m_strname, you must call updatedata (false );
In this way, the updated variable value can be displayed in your Edit!
2,

Updatedata (true) is to pass the control status to its associated variables. Of course, you must associate the control with the variables.
Updatedata (false) transmits the value of the variable associated with the control to the control and changes the control status.
Updatedata refreshes the current dialog box.

Updatedata (true); // used to exchange data in the control on the screen to a variable.
Updatedata (false); // used to display data in the corresponding control on the screen.

3. Edit Control: the variable m_edit associated with the control. When the program is executed, you enter the number 21 in the control and upload the value 21 to m_edit and updatedata (true ). if m_edit is modified, it is uploaded to the control updatedata (false );

Note the following:
When the updatedata () function is used, all the variables bound to the current interface (that is, the corresponding variables are added to the control through the MFC classwizard) will be updatedata (true) update the content of the corresponding control. Similarly, all the content of the control bound with the variable will be updated to the content of the corresponding variable by updatedata (false.

True if you want to accept user input,
Flase

If the data volume is small, it is best to use setdlgitemtext () and getdlgitemtext ()


Important addition:

Getwindowtext () is used to obtain the current content (caption or the text within the control-for the control, you can view the msdn) of the control. It is for a single control;
Updatedata () Acts on the DDX data exchange mechanism of the entire cwnd and is a two-way channel between controls and data.

Bytes -------------------------------------------------------------------------------------------------------------------

Source: http://blog.163.com/xuxiaoqianhz@126/blog/static/16519057720108252554358/

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.