如何在命名空间扩展名之间拖放多个文件 [英] How to Drag and Drop multiple files between Namespace extensions

查看:65
本文介绍了如何在命名空间扩展名之间拖放多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个名称空间扩展项目上,我需要在名称空间扩展之间实现多个文件的拖放。我已使用DragQueryFile API查找文件数。但始终此功能会导致崩溃。

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.

谢谢,
罗宾

推荐答案

这是我的用法

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);
}

这篇关于如何在命名空间扩展名之间拖放多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆