The difference of UpdateData () function parameter True/false in VC __c

Source: Internet
Author: User

The use of UpdateData () function in VC
UpdateData (FALSE) and UpdateData (TRUE) are the opposite process
UpdateData (FALSE) is to update the values of the changes in the program to the control
UpdateData (TRUE) is to update the value entered in the control to your variable
TRUE ===> Control-〉 data member
FALSE ===> data member-〉 control
For example, one of your edit box control C_edit is associated with a variable S_edit
In the program, you used the
s_edit= "CSDN"
But you type "NDSC" in the edit box.
If you are using UpdateData (FALSE), your edit box will be "CSDN".
If you are using UpdateData (TRUE), S_edit will become "NDSC."
If you want to get M_edit's content to take effect immediately
UpdateData (FALSE);
M_edit. UpdateWindow ()//This sentence must not be less, or it will not take effect immediately.
Correction:

If you want to get M_edit's content to take effect immediately
UpdateData (FALSE);
UpdateWindow ()//This sentence must not be less, or it will not take effect immediately.
The edit control does not updatewindow this member function, so direct use of the
For example:
M_name= "";
M_mima= "";
UpdateData (FALSE);
UpdateWindow ();

UpdateData (TRUE);//is used to exchange data from a control on a screen into a variable.

UpdateData (false);//is used to display data in the corresponding control on the screen.

When you use ClassWizard to establish a link between a control and a variable: When you modify the value of a variable, and you want the dialog control to update the display, you should call UpdateData (FALSE) after modifying the variable, and if you want to know what the user entered in the dialog box, You should call UpdateData (TRUE) before accessing the variable.

Ii. assignment and value of the edit box

When assigning and taking values to an edit box:

1, the establishment of a control-type variables, such as M_edit1, with CWnd SetWindowText () and GetWindowText () to assign values and values.

M_edit1.setwindowtext ("Hello");

or GetDlgItem (idc_edit1)->setwindowtext (str);

2, establish a control type of variables, such as M_edit1, with Setdlgitemtext () and GetDlgItemText () to assign values and values

CString str= "Hello":

M_edit1. Setdlgitemtext (IDC_EDIT1,STR);

2, directly build a numerical variable such as m_stredit; Use UpdateData () to control whether to get the variable or to update the variable.

Take value
UpdateData (TRUE);
CString buf = m_edit1;

assigning values
M_edit1= "ok!";
UpdateData (FALSE);

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.