In MFC, we often need to map some variables to the control! Use UpdateDate to call DoDataExchange (CDataExchange * pDX) to exchange variable information!
Add control variables in VS2010: Right-click the control and select Add variable. The add member variable wizard is displayed. Remember to select the control variable check box. Select Value in the category drop-down box. Select the variable type and set the variable name.
For example:
DDX_Text (pDX, IDC_STATICCOUNT, m_sCount); --> value corresponds
Match the Control ID IDC_STATICCOUNT with the m_sCount variable,
Use UpdateDate (TRUE) to write the IDC_STATICCOUNT control data to m_sCount;
Use UpdateDate (FALSE) to read and write m_sCount data to the IDC_STATICCOUNT control;
DDX_Control (pDX, IDC_BSTARTTIME, m_cStartTime); --> control
The control with the ID of IDC_BSTARTTIME corresponds to the m_sCount variable, such as BUTTON.
Now we can change the status of the corresponding control through the m_cStartTime control variable!
M_cStartTime.EnableWindow (FALSE); you can change whether the control is available! If no control corresponds,
Then we can use the equivalent statement: GetDlgItem (IDC_BSTARTTIME)-> EnableWindow (TRUE );
The dialog box data exchange is completed by the DoDataExchange function, which is never directly called in program code. Instead, it is called through another member function of the CWnd class: UpdateData. Call UpdateData to initialize the dialog box control or obtain data from the dialog box.
The UpdateData function has a BOOL type parameter. The default value is TRUE. If the value is TRUE, the function is retrieving data from the dialog box to the member variable. If the value is FALSE, the function is initializing the control of the dialog box.