MFC usage of control variables

Source: Internet
Author: User

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.

 

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.