我在C++ Win32應用程序工作,我實現DragAndDrop
操作,我可以能夠從資源管理器中的文件和文件夾拖放到使用WndProc
電話與WM_DROPFILES
我的應用程序,現在我嘗試從Win32應用程序到資源管理器的DragAndDrop文件和文件夾。如何從Win32應用程序拖動文件和文件夾拖放在資源管理器
我寫了一個示例代碼,將文本從應用程序拖動到資源管理器,使用Karlsson’s Drag-and-Drop C圖書館工作正常,但我的要求是將文件和文件夾從win32應用程序拖放到資源管理器。下面是我的示例代碼放置文本。
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;
}
您的代碼在這裏不會嘗試使用文件操作 –
@DavidHeffernan是的。它的拖放文本的示例代碼,所以我正在尋找拖放文件和文件夾。同樣的方式,我嘗試了CF_HDROP,但它不工作。 – Krish
爲什麼不做一些研究。如果有的話有很多例子。 –