Bind member variables of different types in the dialog box control:
DDX: Dialog Data Exchange Dialog box Data Exchange
DDV: Data validation in the Dialog Data Validate Dialog box
A control can bind multiple variables of different types;
①. Two Methods for binding control type variables-data exchange mechanism:
◆ Use the GetDlgItem function;
CButton * cButton;
CButton = (CButton *) GetDlgItem (IDC_BUTTON1 );
// Use the variable disable button
CButton-> EnableWindow (FALSE );
◆ Use the VC Wizard to bind the generated code and how to manually add it;
② Binding of string type and numeric type variables and data verification mechanism;
String type-the length can be limited;
// Bind the variable
DDX_Text (pDX, IDC_EDIT1, bu_str );
// Limit the length
DDV_MaxChars (pDX, bu_str, 5 );
Value Type-you can limit the size;
DDX_Text (pDX, IDC_EDIT1, num );
DDV_MinMaxInt (pDX, num, 0, 5 );
UpdateData (TRUE );
UpdateData (TRUE); // control flow variable;
UpdateData (FALSE); // variable flow control;
Share: