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);