0

I am working on a namespace extension project, I need to implement multiple files drag and drop between Namespace Extensions. I have used DragQueryFile API to find the the number of files. But Always this Function give a crash.

Could anyone help me by explaining how we can implement this multiple files Drag and drop.

Thanks, Robin

  • 1
    `DragQueryFile` only works with the data format `CF_HDROP` which only supports files/paths with a text representation (e.g. real filesystem files). If you're writing your own namespace extension you probably need to use native COM drag/drop (`DoDragDrop`, `IDataObject`, `IDropSource`, `IDropTarget`, etc). – Jonathan Potter Jul 24 '13 at 02:15
  • Hi Jonathan,thanks for the update. I am using COM Drag and drop only in the project. But I need to drag and drop files between extension. I am able to implement drag and drop for one file if multiple files are selected. Now I want to iterate through the PIDL data and find other elements.could you please provide some light regarding how to iterate through the pidl and find the next items. – user2612741 Jul 25 '13 at 04:52

1 Answers1

0

Here is how I use it

void yourclass::OnDropFiles(HDROP hDropInfo)
{


    TCHAR lpszFile[MAX_PATH] = { 0 };
    UINT uFile = 0;

    uFile = DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, NULL);
    if (uFile != 0)
    {
        for (int i = 0; i < uFile; i++)
        {
            lpszFile[0] = '\0';
            if (DragQueryFile(hDropInfo, i, lpszFile, MAX_PATH))
            {
                std::wstring directory;
                std::wstring filename;
                LVITEM lvi = { 0 };
                lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;

                SplitPath(lpszFile, directory, filename);

                lvi.iSubItem = 0;
                lvi.pszText = LPSTR_TEXTCALLBACK;
                lvi.cchTextMax = MAX_PATH;

                int n = m_wndFileList.InsertItem(&lvi);
                m_wndFileList.SetItemText(n, 0, filename.c_str());
                m_wndFileList.SetItemText(n, 1, directory.c_str());

            }
        }
    }
    DragFinish(hDropInfo);
    return;
    CDialogEx::OnDropFiles(hDropInfo);
}
Michael Haephrati
  • 3,660
  • 1
  • 33
  • 56