简体   繁体   English

在C ++上的两个MFC TreeList之间拖放

[英]Drag&Drop between two MFC TreeList on C++

I Need Drag&Drop item from one TreeList to another ThreeList, but find only tutorials to make this in same TreeList. 我需要拖拽项目从一个TreeList到另一个ThreeList,但只找到教程,使其在同一个TreeList中。 Can anybony help with this? anybony可以帮忙吗? Also im interesting how drag and drop file or folder from file system (window explorer) to TreeList? 我也很有意思如何将文件系统(窗口浏览器)中的文件或文件夹拖放到TreeList? Im using MFC C++. 我正在使用MFC C ++。 Thanks! 谢谢!

Without omitting the obligatory real answer to all MFC questions (which is "don't use MFC—unless it's 1997 where you live" ), OLE drag & drop will help you achieve both goals. 如果没有省略所有MFC问题的强制性真实答案( “不使用MFC - 除非它是你居住的1997年” ),OLE拖放将帮助你实现这两个目标。

Though I don't have an MSVC handy at the moment, this example seems fairly thorough...with move, copy, and scrolling: 虽然我目前没有MSVC方便,但这个例子似乎相当彻底......有移动,复制和滚动:

http://www.ucancode.net/CPP_Library_Control_Tool/OLE-DRAG-DROP-TREE-Control-CTreeCtrl-VC-Article.htm http://www.ucancode.net/CPP_Library_Control_Tool/OLE-DRAG-DROP-TREE-Control-CTreeCtrl-VC-Article.htm

You can use that as a basis. 您可以将其作为基础。 But then for dropping-in-from-Windows-Explorer, throw in an additional check in your OnDragEnter() and OnDragOver() methods to see if CF_HDROP data is available: 但是,对于从Windows资源管理器中删除,请在OnDragEnter()OnDragOver()方法中进行额外检查,以查看CF_HDROP数据是否可用:

if (pDataObject->IsDataAvailable(CF_HDROP)) {
   /* Extract the DROPFILES data out of the pDataObject */
}

This article goes into the details of how to get a filename list out of that wacky DROPFILES OLE structure: 本文详细介绍了如何从那个古怪的DROPFILES OLE结构中获取文件名列表:

http://www.codeproject.com/Articles/840/How-to-Implement-Drag-and-Drop-Between-Your-Progra http://www.codeproject.com/Articles/840/How-to-Implement-Drag-and-Drop-Between-Your-Progra


For contrast, if you want to see something that's NOT terribly designed, look at the Qt Drag & Drop samples: 相比之下,如果你想看到一些设计不是很糟糕的东西,请看Qt拖放样本:

http://doc.qt.nokia.com/4.7-snapshot/dnd.html#examples http://doc.qt.nokia.com/4.7-snapshot/dnd.html#examples

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM