Page 206 - DCAP408_WEB_PROGRAMMING
P. 206

Windows Programming




                    Notes          The new  DDX_Text macro entry automates data transfer  between the control identified by
                                   IDC_CUSTOM_EDIT and your m_strCustomEditmember variable.
                                   If you were to add a control map for the edit control, you'd see a CEdit member variable entry
                                   added to the class definition, and a corresponding DDX_Control macro to map it to the control
                                   ID. Consider this example:

                                   DDX_Control(pDX, IDC_CUSTOM_EDIT, m_editCustom);
                                   If you insert other variable types, you'll see different DDX_ macros used to map the various
                                   types of controls to various data types. Table 12.1 lists some of these controls.

                                            Table 12.1:  Some  Common  Controls and  Their Mapping  Classes/Variables


                                            Control         Mapping Class       Allowable Mapped Data Types
                                      Static             CStatic            CString
                                      Edit               CEdit              CString, DWORD, UINT, int, long
                                                                            double, float, BOOL, short
                                                                            COleDateTime & ColeCurrency
                                      Button             CButton            None
                                      CheckBox           CButton            BOOL
                                      3-State CheckBox   CButton            int
                                      Radio              CButton            int
                                      ListBox            CListBox           CString, int
                                      ComboBox           CComboBox          CString, int
                                      Extended Combo     CComboBoxEx        CString, int
                                      ScrollBar          CScrollBar         int
                                      Spin               CSpinButtonCtrl    None
                                      Progress Bar       CProgressCtrl      None
                                      Slider Control     CSliderCtrl        int
                                      List Control       CListCtrl          None
                                      Tree Control       CTreeCtrl          None
                                      Date Time Picker   CDateTimeCtrl      CTime, COleDateTime
                                      Month Calendar     CMonthCalCtrl      CTime, COleDateTime

                                   You can add some simple validation maps to certain controls, such as Edit controls. Depending
                                   on the variable type mapped, the lower section of the Member Variables tab displays a section
                                   that lets you specify validation information.

                                   If you map a CString to an Edit control, for example, you can set the validation rules to limit the
                                   maximum number of characters allowed in the Edit control. If you map an integer to the Edit
                                   control, you can set upper and lower ranges for the entered value.

                                   If you set any of these validation rules, ClassWizard adds DDV_ routines to the DoDataExchange()
                                   function to perform validation, like this:
                                   DDV_MaxChars(pDX, m_strCustomEdit, 10);

                                   Several different DDV_ routines exist for the various types of validation rules, member variables,
                                   and control types.






          200                               LOVELY PROFESSIONAL UNIVERSITY
   201   202   203   204   205   206   207   208   209   210   211