【问题标题】:MFC CListCtrl drag file to Windows ExplorerMFC CListCtrl 拖动文件到 Windows 资源管理器
【发布时间】:2013-03-20 05:08:23
【问题描述】:

我正在编写一个 MFC 应用程序。

我想将文件从我的应用程序中的CListCtrl 拖到 Windows 资源管理器中。

怎么做?

【问题讨论】:

    标签: c++ winapi visual-c++ mfc explorer


    【解决方案1】:

    您需要连接LVN_BEGINDRAG 以检测拖放的开始,然后调用DoDragDrop 并使用填充了文件信息的基于IDataObject 的数据源(最容易处理的格式是CF_HDROP)。 Windows shell 处理所有其他事情。

    幸运的是,在 MFC 课程COleDataSource 中已经为您完成了大部分的腿部工作。还有一些很好的例子:

    Code Project - How to Implement Drag and Drop Between Your Program and Explorer

    MSDN - Transferring Shell Objects with Drag-and-Drop and the Clipboard

    【讨论】:

      【解决方案2】:

      您需要在您的CListCtrl 派生类中覆盖OnDrop() 并提供COleDataSource

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-19
        相关资源
        最近更新 更多