General OLE Concepts

One of the most attractive aspects of OLE is that it is completely modular. It is designed so that each component can exist, for the most part, on its own. For example, you can add drag and drop support to your application without adding in-place activation, automation, or compound storage.

Even if your application only uses a small part of OLE, the Component Object Model (COM) enables other applications to know what your application's OLE capabilities are. COM is the fundamental, underlying model that OLE is based upon; all OLE objects are also component objects.

COM stipulates that any component object must control its own life span and be able to tell other objects about its capabilities in a strictly defined manner. To control its life span, a component object maintains a reference count. Capabilities are grouped into logical sets called interfaces; each interface is a set of member functions necessary to support a certain capability. The "strictly defined manner" that component objects must use is itself an interface, which is called IUnknown. Because all OLE interfaces are derived from IUnknown, they are component objects. IUnknown has three member functions: QueryInterface, AddRef, and Release.

An object uses QueryInterface to tell other objects about its capabilities. If the object implements the requested interface, it returns a pointer to the interface. If it does not implement it, it returns the E_NOTIMPL error value stating that the object does not support the requested interface. AddRef and Release are used to control the object's life span. An object's AddRef member function is called when another object holds a pointer to the object, and the Release member function is called when the pointer is no longer needed. If a call to Release causes the object's reference count to go to zero, the object can safely unload itself.

COM provides a couple of immediate benefits:

  • An object can determine in advance if another object supports a certain feature. If the other object does not support the feature, the calling object can react accordingly.

  • Objects do not remain in memory longer (or shorter) than necessary, and they do not rely on the user to launch or close them.

The OLE data transfer mechanism is a crucial element of drag and drop support. Data transfer in OLE allows objects to be very specific about the data that they transfer. Instead of simply being able to transfer a plain old bitmap, an object can now transfer a bitmap of the object's contents rendered for a printer device and stored in a stream to be released by OLE.

To accomplish this, OLE uses the IDataObject interface and the FORMATETC and STGMEDIUM structures. Applications implement IDataObject to accomplish all data transfer in OLE; it includes member functions that set and retrieve an object's data, enumerate the available data formats, and receive data change notifications. FORMATETC and STGMEDIUM provide the specific details about the data that is being transferredpics/WIN3200090001.gifthat is, the target device, aspect, storage medium, and release method.

Every drag and drop operation involves two objects: a source and a target. The source object contains the data to be dragged, and the target object accepts the dragged data.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database