Page 199 - DCAP408_WEB_PROGRAMMING
P. 199
Unit 12: Dialog Boxes (II)
12.1 Exchanging Data with a Dialogue Box – Global Variable Notes
Method and Pointer Method
This topic lists the DDX_OC functions used to exchange data between a property of an OLE
control in a dialog box, form view, or control view object and a data member of the dialog box,
form view, or control view object.
DDX_OC Functions
DDX_OCBool Manages the transfer of BOOL data between a property of an OLE control and
a BOOL data member.
DDX_OCBoolRO Manages the transfer of BOOL data between a read-only property of an OLE
control and a BOOL data member.
DDX_OCColor Manages the transfer of OLE_COLOR data between a property of an OLE
control and an OLE_COLOR data member.
DDX_OCColorRO Manages the transfer of OLE_COLOR data between a read-only property of an
OLE control and an OLE_COLOR data member.
DDX_OCFloat Manages the transfer of float (or double) data between a property of an OLE
control and a float (or double) data member.
DDX_OCFloatRO Manages the transfer of float (or double) data between a read-only property of
an OLE control and a float (or double) data member.
DDX_OCInt Manages the transfer of int (or long) data between a property of an OLE control
and an int (or long) data member.
DDX_OCIntRO Manages the transfer of int (or long) data between a read-only property of an
OLE control and an int (or long) data member.
DDX_OCShort Manages the transfer of short data between a property of an OLE control and
a short data member.
DDX_OCShortRO Manages the transfer of short data between a read-only property of an OLE
control and a short data member.
DDX_OCText Manages the transfer of CString data between a property of an OLE control
and a CString data member.
DDX_OCTextRO Manages the transfer of CString data between a read-only property of an OLE
control and a CString data member.
If you’re new to Microsoft Foundation Class (MFC) programming, or C++ programming in
general, then there are probably many areas you find confusing or hard to understand. Even (or
should I say “especially”?) veteran programmers have questions from time to time. If I had to
pick one area where I receive the most inquiries, it would have to be Dialog Data Exchange
(DDX) and Dialog Data Verification (DDV). Collectively, these mechanisms provide you a
means to transfer information from your main application to and from a dialog box you wish to
display. And although they may seem cryptic at first, spending the time to learn to use them will
save you pain and agony in the long run!
First, how would we build a dialog in the days of ‘C’ and the Windows SDK? Well, we’d most
likely insert a command into a menu, which would trigger a call to DialogBox(), or a derivative,
in our command message handling code. One of the parameters passed to DialogBox() is a
pointer to a subroutine we created to actually bring up the dialog box. If this dialog box required
initialization, such as filling in default text in an edit box, we’d (probably) either hard-code the
text into our WM_INITDIALOG handler or use a global variable as a text container. If the user
modified the text, we’d have to write the new string back to the global variable or find some
other viable means of retrieving the string prior to the dismissal of the dialog box.
LOVELY PROFESSIONAL UNIVERSITY 193