DDX and DDV Methods This article mainly introduces DDX and DDV architectural structures, this article also helps you understand DDX or DDV processes and how to extend ClassWizard so that it can use users. Let's take a look at the dialog data exchange. Note that during the two processes above, the key issue is the overload of the virtual function. We often see the following code in our code generated by ClassWizard: Void CMYDIALOG :: DODATAEXCHANGE (CDataExchange * PDX) {cdialog :: DODATAEXCHANGE (PDX); // call base class // {{AFX_DATA_MAP (CMYDIALOG) < Data_exchange_function_call> //}} AFX_DATA_MAP} where the AFX is controlled by ClassWizard, only code included in the middle of the AFX can be managed by ClassWizard. If the user does not want some things to manage ClassWizard, then remove these things out of AFX. . However, in general, it is still not doing so. There is still a paragraph in the above code, that is,
m_pdlgWnd: It refers to a window including the current control, which is used to prevent global calls of DDX_ and DDV_; PrepareCtrl: is a dialog control for preparing data exchange, which returns a window handle. If the verification process fails, you have to use this handle to continue the focus of the original window. Please note: PrepareCtrl is used to prepare non-editing controls. For controls that can be input and edited, use prepareEditCtrl; fail: When the verification process fails, call the fail process, the main role of this function is to restore the focus of the original window. Keep the input and selection content in the original window, issue an Exception. We can extend DDX / DDV through the following methods. Adding new data types, such as: CTIME adds a new exchange process (DDX _ ???) can be: Void Pascal DDX_TIME (CDATAEXCHANGE * PDX, INT NIDC, CTIME & TM); Add a new verification process (DDV _ ???) Yes: Void Pascal DDV_TIMEFUTURE (CDataExchange * PDX, CTIMETM, BOOL BFUTURE);
The following verification is that the number of entries is verified is between 0 to the largest age (for people may be 500 years old): DDV_MINMAX (PDX, AGE, 0, M_MAXAGE); the above code cannot be managed by ClassWizard, so Outside the // {{AFX_DATA_MAP (CMYCLASS)). Here is some of the conditional validations, what it means, I don't have much no mouth, look at this article, knowing a few English, everyone will understand it. // {{AFX_DATA_MAP (CMyClass) DDX_Check (pDX, IDC_SEX, m_bFemale); DDX_Text (pDX, IDC_EDIT1, m_age); //}} AFX_DATA_MAP if (m_bFemale) DDV_MinMax (pDX, age, 0, m_maxFemaleAge); else DDV_MinMax (pDX , age, 0, m_maxmaleage; of course, if we can manage DDX / DDV in ClassWizard, isn't that better. ClassWizard supports the subset of DDX and DDV, and we will get some convenient by let ClassWizard manage DDX and DDV. This is especially true when repeatedly. If you want to implement this function, you can compile in DDX.CLW or in the process of engineering, join the corresponding function portal. In the process of engineering. CLW, write the user-defined function entry in the [General Info] segment, or add the corresponding code in the [ExtradDX] segment of DDX.CLW, but please pay attention to DDX.CLW Place the / program files / devstudio / sharedide / bin directory. Of course, if DDX.CLW does not exist, then the user creates itself. If you only want to use a specific function entry in your project, you can add the corresponding function entry to the project. CLW can be. If you want to use in multiple projects and later work, you can join the [EXTRADDX] segment in DDX.CLW. Let's take a look at what we should write: EXTRADDXCOUNT = n // n is EXTRADDX? The number of rows after the following row EXTRADDX? =
Examples can refer to the example Chkbook with the VC itself.