Reputation: 20396
I am writing an MFC application.
I want to drag file from a CListCtrl
in my application to Windows Explorer.
How to do that?
Upvotes: 1
Views: 1846
Reputation: 2965
You need to override OnDrop()
in your CListCtrl
derived class and provide a COleDataSource
.
Upvotes: 3
Reputation: 3874
You need to hook up LVN_BEGINDRAG
to detect the beginning of a drag drop and then call DoDragDrop
with an IDataObject
based data source populated with the file information (easiest format to handle is CF_HDROP
). The Windows shell handles everything else.
Fortunately much of the leg work has already been done for you in the MFC class COleDataSource
. There are also some great examples available:
Code Project - How to Implement Drag and Drop Between Your Program and Explorer
MSDN - Transferring Shell Objects with Drag-and-Drop and the Clipboard
Upvotes: 4