am working in C++ Win32 Application and I implementing DragAndDrop
operation, I can able to drag a files and folders from explorer to my application using WndProc
calls with WM_DROPFILES
, Now I trying for DragAndDrop files and folders from Win32 application to explorer.
I write a sample code to drag a text from application to explorer using Karlsson’s Drag-and-Drop C Library its working fine for text drop but my requirement is drag and drop files and folders from win32 application to explorer. below is my sample code for drop text.
case WM_LBUTTONDOWN:
{
char* text = "Hello, World! This is the drop source.";
HANDLE text_on_heap;
PMYDROPSOURCE text_drop_source;
CLIPFORMAT cf[1] = { CF_TEXT };
text_on_heap = GlobalAlloc(GMEM_FIXED, strlen(text) + 1);
if (NULL == text_on_heap) break;
strcpy((char*)text_on_heap, text);
text_drop_source = CreateMyDropSource(FALSE, cf, &text_on_heap, 1);
if (NULL != text_drop_source)
{
/* Drop source created, so begin the drag. This will block. */
MyDragDropSource(text_drop_source);
/* Drag-drop is done so destroy the drop source. */
FreeMyDropSource(text_drop_source);
}
/* Free up the buffer; drag-drop is finished. */
GlobalFree(text_on_heap);
return TRUE;
}