DDX and DDV method

zhaozj2021-02-08  479

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, , its form can be DDX_CUSTOM (PDX, NIDC, Field), or DDV_CUSTOM (PDX, Field, ...) ;, All about DDX and DDV The definition is defined in file 'AFXDD_.h'. Definition of function initialization between // {AFX_DATA_INIT and / /}} AFX_DATA_INIT in the constructor of the class. The CWnd :: Updatedata function is usually used, we often take some True or False's values, let us take a look, what is done if it is TRUE. It is actually the data exchange. We generally don't have to use the dialog boxes like the following data exchange process, but if we can understand, it is certainly much better. We can view the DODATAEXCHANGE member function as a Serialize member function. Anyway, both are all in the class, or send data from the class. We must see a PDX thing in the code. It is a parameter. It is used to perform data exchange parameters. We already know that in the Updatedata to transmit a parameter, represent the direction, then we look at the PDX Indicates that the data transfer direction (this direction is to indicate whether the data is transmitted from the class, or transmitted to the class): If m_bsaveandvalidate is a false, transfer the data to the corresponding control, and the data is transmitted. If m_bsaveandvalidate is true, transfer the data to the class, data transfer enters classes! After setting M_BsaveAndValidate, the verification (data validity) process is performed. There are several functions below, but it is not said:

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? = ; ; ; [; ; ; ; [; ] // here? On behalf of 1 to n, specify what type of DDX defined in the specified table; each of the above defined parts; spaced apart, their meaning we are below: = it is a letter, indicating the dialog control What type: E = Edit C = Two-State Check Box C = Tri-State Check Box R = First Radio Button In a Group L = Non-Sorted List Box L = Sorted List Box M = Combo Box (with Edit Item) N = Non-sorted Drop List N = Sorted Drop List If DDX needs to be inserted on the list, use 1. It is generally used to transmit control attributes DDX procedures.

This domain is used to transmit some of the 16-bit VBX controls. For 32-bit products, VBX is not supported at all, and the = string placed in the properties combo box; = in the head A single tag that appears in the file. In the above example, it should be set to cTIME; = is empty = initial value of 0 or empty. If it is empty, it is not necessary to initialize in the initial line // {{AFX_DATA_INIT. This option is only used when the member is a class, because for the initialization of the class, a class of initialization functions, however, for other types or initialization; = DDX process identifier, DDX process C function Name must start with DDX, but this DDX should not include in the identifier. in the above example should be Time, ClassWizard can add DDX when writing a function writes the function. = Comment. What can users like to put anything? DDV process identifier, not after all DDX processes, there must be a DDV process. For convenience, the DDV process can be used as part of the integrated transmission. You can write this, but does not add parameters, ClassWizard will not add DDV without parameters to the code. DDV procedures must have DDV as a prefix, but don't have to be added, because ClassWizard can add itself. The following is the DDV parameter: = String on the programming item, you can use & as a format character of the acceler key = parameter type, they have: d = int u = unsigned D = long int That IS, long) u = long unsigned (That is, dword) f = float f = double s = string

Examples can refer to the example Chkbook with the VC itself.

转载请注明原文地址:https://www.9cbs.com/read-843.html

New Post(0)