Use of UpdateData () function in VC

Source: Internet
Author: User

UpdateData (FALSE) and UpdateData (TRUE) are the opposite process
UpdateData (FALSE) is the change in the program to update the value of the control to
UpdateData (TRUE) is to update the value entered in the control into your variable.

TRUE ===> Control-〉 data member
FALSE ===> data member-〉 control
Like your one. edit box control C_edit associated with variable S_edit
You used it in the program.
s_edit= "CSDN"
But you enter "NDSC" in the edit box
If you use UpdateData (FALSE), your edit box will be "CSDN"
If you use UpdateData (TRUE), S_edit will become "NDSC".

If you want to make the content of M_edit effective immediately
UpdateData (FALSE);
M_edit. UpdateWindow ();//This sentence must not be less, otherwise it will not take effect immediately

Correction:

If you want to make the content of M_edit effective immediately
UpdateData (FALSE);
UpdateWindow ();//This sentence must not be less, otherwise it will not take effect immediately
The edit control does not have this member function UpdateWindow, so use directly
For example:
M_name= "";
M_mima= "";
UpdateData (FALSE);
UpdateWindow ();

============================

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

UpdateData (false);//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 box control to update the display, you should call UpdateData (FALSE) after modifying the variable, or if you want to know what the user entered in the dialog box, You should call UpdateData (TRUE) before accessing the variable.

Ii. about the assignment and value of the edit box

When assigning and taking values to an edit box:

1, build a control type of variable, 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 variable, such as M_edit1, with Setdlgitemtext () and GetDlgItemText () to assign values and values

CString str= "Hello":

M_edit1. Setdlgitemtext (IDC_EDIT1,STR);

2, directly constructs a numerical shape variable such as m_stredit; Use UpdateData () to control the resulting variable or update it.

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

Assign value
M_edit1= "ok!";
UpdateData (FALSE);

UpdateData (False) is the opposite of UpdateData (TRUE) procedure UpdateData (FALSE) is the value changed in the program

New to control UpdateData (TRUE) is to update the value entered in the control to your variable to true ===> control-〉 data

Member FALSE ===> data member-〉 control such as your one edit box control C_edit associated with the variable S_edit in the program you use

s_edit= "CSDN" but you enter "NDSC" in the edit box if you use UpdateData (FALSE) in your edit box

Will be "CSDN" if you are using UpdateData (TRUE) S_edit will become "NDSC" if you want M_edit content to be born immediately

Effective UpdateData (FALSE); M_edit. UpdateWindow ();//This sentence can not be less, otherwise it will not be effective immediately fix: If you want to make

The contents of the M_edit immediately take effect UpdateData (FALSE); UpdateWindow ();//This sentence must not be less, otherwise it will not take effect immediately

The edit control does not updatewindow this member function, so use it directly for example: M_name= ""; M_mima= "";

UpdateData (FALSE); UpdateWindow (); ============================

UpdateData (TRUE);//is used to exchange data in controls on a screen into a variable. UpdateData (false);//For data in the screen

displayed in the corresponding control in the screen. When you use ClassWizard to establish a link between a control and a variable: When you modify the variable's

Value, and you want the dialog box control to update the display, you should call UpdateData (FALSE) after modifying the variable, if you want to know if the user is

In the dialog box, you should call UpdateData (TRUE) before accessing the variable. Ii. about the assignment and value of the edit box

When assigning and taking values in a frame: 1, build a controlled variable, such as M_edit1, with CWnd's SetWindowText () and

GetWindowText () to assign and take values. M_edit1.setwindowtext ("Hello"); Or

GetDlgItem (IDC_EDIT1)->setwindowtext (str); 2, establish a control type of variable, such as M

_edit1, use Setdlgitemtext () and GetDlgItemText () to assign values and values CString str= "Hello":

M_edit1. Setdlgitemtext (IDC_EDIT1,STR); 2, directly constructs a numerical shape variable such as m_stredit; Use

UpdateData () to control whether the variable is obtained or updated. Value UpdateData (TRUE); CString buf =

M_edit1; Assignment m_edit1= "ok!"; UpdateData (FALSE);

Use of UpdateData () function in VC

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.