C# 在 Windows 中拖放的通知

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-01 09:11:51  来源:igfitidea点击:

Notification of drop in drag-drop in Windows

提问by Joel Lucsy

My C#program has a list of files that can be dragged from it and dropped into another program. My requirements are that the file be copied to a different directory first.

我的C#程序有一个文件列表,可以从中拖动并放入另一个程序中。我的要求是首先将文件复制到不同的目录。

So, can I be notified of the drop operation so that I can only copy the file if operation succeeds? I'd rather wait till I know it needs to be copied before actually performing the copy.

那么,我是否可以收到删除操作的通知,以便只有操作成功才能复制文件?我宁愿等到我知道它需要被复制,然后再实际执行复制。

Also, is it possible to know what program the drop operation is occurring in? Ideally I'd like to alter the filepath based on who or what its being dropped.

另外,是否有可能知道删除操作发生在哪个程序中?理想情况下,我想根据删除的人或内容来更改文件路径。

The solution to this can be in any .NET language or C/C++with COM.

对此的解决方案可以使用任何 .NET 语言或C/C++使用COM.

回答by Stu

There are a few ambiguities in your question. What operation needs to be successful?

你的问题有一些歧义。需要什么操作才能成功?

For everything you want to know about drag and drop, browse through these search results (multiple pages worth):

对于您想了解的有关拖放的所有信息,请浏览这些搜索结果(值得多页):

Raymond Chen on drag and drop

Raymond Chen 拖放

回答by Nick

So, you intend to modify the data being dropped based on the drop target? I don't think this is possible; after all, you populate the data when the drag is initiated.

那么,您打算根据放置目标修改正在放置的数据吗?我认为这是不可能的;毕竟,您在开始拖动时填充数据。