Being a Drop Target

HomeOverviewHow Do I

Because DRAWCLI is an OLE container, it needs drop target functionality to meet the Windows 95 requirements. (Conversely, an OLE server needs drop source functionality.)

MFC provides support for drop-target functionality through the COleDropTarget class and certain member functions in the CView class. Being a drop target involves the following tasks:

Most of these tasks are application-specific, so MFC can’t complete them for you. However, MFC does provide support for scrolling a document during a drag-and-drop operation, which is traditionally one of the more difficult tasks involved in being a drop target. The following sections describe how the other tasks are completed by the DRAWCLI sample.

One requirement for being a drop target was already satisfied by the previous version of DRAWCLI: the ability to perform a paste operation from a COleDataObject object. The previous version of DRAWCLI allowed OLE embedded objects to be inserted with the Paste command; the new version of DRAWCLI takes advantage of this fact by reusing the existing CDrawView::PastEmbedded function. If your container application doesn’t support this use of the Paste command, you should add that before implementing drop-target functionality. For information on creating embedded objects with the Paste command, see Data Objects and Data Sources (OLE) and Clipboard: Copying and Pasting Data.