
If your application is a server, use COleServerItem::DoDragDrop.

Otherwise, construct a COleDataSource object, initialize it with the selection, and call the data source object's DoDragDrop member function. If your application is a container and the selected data is a linked or an embedded object of type COleClientItem, call its DoDragDrop member function. The MFC OLE samples OCLIENT and HIERSVR follow these guidelines. Recommended user interface guidelines define the beginning of a drag operation as when a WM_LBUTTONDOWN event occurs on a point inside some selected data. The first step is to determine what events begin a drag operation. Basic implementation of a drop source is relatively simple. To get your application to provide data to a drag-and-drop operation, you implement a drop source. It's also helpful to examine the MFC OLE samples OCLIENT and HIERSVR.
#Sample manager drag and drop how to
The Data objects and data sources (OLE) articles explain how to implement data transfer in your applications. This feature makes your application much easier to use. If an application implements both drop-source and drop-target support, you can drag and drop between child windows, or within one window. Any application could be a drop source, a drop target, or both. It may be implemented in either a container or a server application. Using OLE drag and drop, data can be transferred easily from one location to another: Within a document, between different documents, or between applications. There's only one requirement: Both the drop source and drop target must be open, and at least partially visible on the screen. The operation eliminates the need for menus, and it's quicker than the copy/paste sequence. You drop it by releasing the mouse button. You select the data from the source window (the "drop source"), then you drag it to the destination (the "drop target"). When you use OLE drag and drop, you remove two steps from the process. It allows you to drag and drop any data that could also be placed on the Clipboard. Drag and drop in OLE is much more general. The File Manager can only handle filenames, and is designed specifically to pass filenames to applications. The OLE drag-and-drop feature is different from the File Manager drag-and-drop mechanism. Finally, you choose Edit > Paste from the menu. Then you move to the destination app or window, and place the cursor in the target location. You select the data, and choose Cut or Copy from the Edit menu. When you use the Clipboard to copy or paste data, a number of steps are required. The drag-and-drop feature of OLE is primarily a shortcut for copying and pasting data.
