Objective Views : Chapter 7 The Canvas : OLE Drag-and-Drop
OLE Drag-and-Drop
Objective Views allows you to use OLE drag-and-drop for moving components. You can only use this functionality if you initialized the OLE libraries in your application. To initialize the libraries, add a call to AfxOleInit() in the InitInstance() method of your application object.
Using OLE drag-and-drop enables the end-user to drag components from one window to another. It also supports the dragging copy operation. The dragging copy operation copies components the end-user is dragging to the new location instead of moving them. If you do not want to support this functionality or load the OLE DLLs, do not initialize OLE. When OLE is not initialized, the standard drag-and-drop capabilities included in the CODController object are available.
Figure 67 – OLE Drag-and-Drop class hierarchy
CODDropSource
The drop source is created in the controller when the user initiates a move operation. It is responsible for determining when a drag operation begins, in addition to providing feedback during the drag operation, and determining when the drag operation ends.
CODDropTarget
The drop target handles the receiving end of the drag-and-drop operation. It determines where components are dropped in the window. Then, it performs the move or copy when the drag operation ends.
OLE Drag-and-Drop and Metafiles
Metafile components can also be added to the canvas from other Windows applications using OLE drag-and-drop and the clipboard. Any Windows application that supports the CF_ENHMETAFILE format for OLE drag-and-drop or clipboard operations can be used to copy metafiles onto the canvas. When a metafile is dropped onto the canvas, a CODMetafileComponent is created to contain the new metafile. For example, you can drag-and-drop Visio symbols into your Objective Views applications.
Objective Views also supports the CF_ENHMETAFILE format when it copies components to the clipboard or starts an OLE drag operation. This allows Objective Views components to be copied to any Windows application that supports pasting or dropping of metafiles. For example, you can drag-and-drop one or more symbols from your Objective Views application into Microsoft Word. This allows a great deal of interoperability with other Windows applications.
By default, support for the enhanced metafile format is enabled for clipboard and drag- and-drop operations. It is possible to disable support for enhanced metafile format by calling the function EnableClipboardEnhMetafiles(). Example 5 is an sample of a controller class that disables support for the enhanced metafile format.
Example 5 – Disabling enhanced metafile support
CMyController::CMyController(CODViewport* pViewport)
{
EnableClipboardEnhMetafiles(FALSE);
}