Programming with Microsoft Visual C++.NET 6ed [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Programming with Microsoft Visual C++.NET 6ed [Electronic resources] - نسخه متنی

George Shepherd, David Kruglinski

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید


The <i class="emphasis">IDataObject </i>Interface






The IDataObject Interface


The IDataObject interface is used for Clipboard transfers and drag-and-drop operations, but it's also used in compound documents, ActiveX controls, and custom OLE features. In his book Inside OLE, 2d ed. (Microsoft Press, 1995), Kraig Brockschmidt says, "Think of objects as little piles of stuff." The IDataObject interface helps you move those piles around, no matter what kind of stuff they contain.

If you were programming at the Win32 level, you'd write C++ code that supported the IDataObject interface. Your program would then construct data objects of this class, and you'd manipulate those objects using the IDataObject member functions. In this chapter, you'll see how to accomplish the same results using MFC's implementation of IDataObject. We'll start by taking a quick look at why the OLE Clipboard is an improvement over the regular Windows Clipboard.


How IDataObject Improves on Standard Clipboard Support


MFC has never provided much support for the Windows Clipboard. If you've written programs for the Clipboard, you've used Win32 Clipboard functions such as OpenClipboard, CloseClipboard, GetClipboardData, and SetClipboardData. One program copies a single data element of a specified format to the Clipboard, and another program selects the data by format code and pastes it. Standard Clipboard formats include global memory (specified by an HGLOBAL variable) and various Graphics Device Interface (GDI) objects such as bitmaps and metafiles (which are specified by their handles). Global memory can contain text as well as custom formats.

The IDataObject interface picks up where the Windows Clipboard leaves off. To make a long story short, you transfer a single IDataObject pointer to or from the Clipboard instead of transferring a series of discrete formats. The underlying data object can contain a whole array of formats. Those formats can carry information about target devices, such as printer characteristics, and they can specify the data's aspect, or view. The standard aspect is content. Other aspects include an icon for the data and a thumbnail picture.

Note that the IDataObject interface specifies the storage medium of a data object format. Conventional Clipboard transfer relies exclusively on global memory. The IDataObject interface permits the transmission of a disk filename or a structured storage pointer instead. Thus, if you want to transfer a very large block of data that's already in a disk file, you don't have to waste time copying it to and from a memory block.

In case you were wondering, IDataObject pointers are compatible with programs that use existing Clipboard transfer methods. The format codes are the same. Windows takes care of the conversion to and from the data object. Of course, if an OLE-aware program puts an IStorage pointer in a data object and puts the object on the Clipboard, older, non-OLE-aware programs will not be able to read that format.



/ 319