|
In a dialog based application, data is transferred between the dialog window
and the corresponding dialog class member variables by means of CDialog’s
virtual function DoDataExchange(); however, we do not call this function
explicitly.
DoDataExchange() is called as a result of a call to the UpdateData()
function. When UpdateData() is called, it is passed a Boolean parameter that
indicates the direction of the data transfer. UpdateData(TRUE) initiates a
transfer of data from the dialog window controls to the associated dialog class
member variables. And a parameter of FALSE would transfer data from the member
variables to the dialog window controls.
As in UpdateData(), DoDataExchange() is alerted to the data direction through a
single parameter which is a pointer to a whole new class of object:
CDataExchange. It is a class that contains information concerning a specific
data transfer and holds a flag that indicates the data transfer direction and a
pointer to the parent window of the controls. Within the DoDataExchange()
function, the CDataExchange object is passed only to the functions that perform
the actual data transfers—the DDX functions. These are called the Dialog
data Exchange Functions.
The DDX routines are used for both data transfer (DDX_CBString(), DDX_Text(),
etc.) and are called as Value functions, and for making the connection between a
member object and its control (DDX_Control()), which are called Control
functions.
A listing of all the DDX functions is given here:
DDX_Control() Gets a pointer to the control.
DDX_Radio() Transfers radio button data.
DDX_Check() Transfers check box data.
DDX_Text() Transfers edit control data; works for many data types,
including CString, int, long, float, double, etc.
DDX_LBString() Transfers the list box’s selected string.
DDX_CBString() Transfers the combo box’s selected string.
DDX_LBIndex() Transfers the index of the list box’s selection.
DDX_CBIndex() Transfers the index of the combo box’s selection.
DDX_LBStringExact() Transfers the list box’s exact selected string.
DDX_CBStringExact() Transfers the combo box’s exact selected string.
DDX_Text() represents many functions that allow transfer of various types
of values to and from an edit control. When this function is overloaded, all
these functions have the same name, DDX_Text(); they are distinguished by their
argument types.
The DDX_LBStringExact() and DDX_CBStringExact() functions select strings in the
combo or list boxes only when an exact match is made. The DDX_LBString() and
DDX_CBString() functions select the first element in the list that has the
appropriate prefix.
|