A consumer is any piece of code that obtains and uses an IDataObject pointer. As we'll see in Chapters 12 and 13, the OLE Clipboard and OLE Drag and Drop technologies are two methods of obtaining this pointer. In this chapter, however, we can demonstrate a number of consumer features through a client for the DDataObj and EDataObj samples. This client is DataUser, found in CHAP10\DATAUSER, where all the code is in DATAUSER.CPP. When you run this sample, you'll see the window shown in Figure 10-3. Here the Data Object menu allows you to select the type of object to use (server and data size) as well as to send either GetData or QueryGetData calls to that object's IDataObject interface.
Figure 10-3.
The DataUser program showing the Data Object menu.
DataUser initially creates three in-process data objects from DDataObj by using CoCreateInstance: one for the small data set (CLSID_DataSmall), one for the medium data set (CLSID_DataMedium), and one for the large data set (CLSID_DataLarge). The Use EXE Object menu item will destroy these three objects and create new ones from the local server, EDataObj, instead. The Use DLL Object menu item will destroy the objects once again and switch back to DDataObj.
One of these three objects is always marked as the current object (stored in CApp::m_pIDataObject) so that any IDataObject call you select through the Data Object menu will be sent to that object. The small data object is the default. You can change the current object—the data size under consideration—through the Data Size menu item, which has the subitems Small, Medium, and Large. Any change in the server being used will reset the current object to the small one.