设置FWF_DESKTOP标志后,无法将文件拖放到IShellView [英] Can't drop files to IShellView when FWF_DESKTOP flag set

查看:88
本文介绍了设置FWF_DESKTOP标志后,无法将文件拖放到IShellView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一个IShellBrowser来托管IShellView对象.当我调用IShellView :: CreateViewWindow时,我设置了FWF_DESKTOP标志.在IShellView :: UIActivate之后,其创建的视图窗口不能接受用户在其上的拖放文件,但可以将其拖动到其他资源管理器窗口.我试图通过IShellFolder :: CreateViewObject和RegisterDragDrop获取IDropTarget到视图窗口,它的工作原理.但是,当我将文件从资源管理器中拖到它时,没有显示任何拖拽图像(这似乎是旧样式的D&D),而且我也无法在同一窗口中拖放项目.如果我用FWF_NONE创建ViewWindow,一切都很好.但为什么?

当我指定FWF_DESKTOP时,如何使拖放正常工作?已设置FWF_DESKTOP.
因此,首先,在一个类中实现IDropTarget.然后,您应该找到底层的ListView并使用ListView的HWND和您的类的实例调用RegisterDrapDrop.
看着这里也很好,另一个人一直在尝试类似的事情:
http://us.generation-nt.com/answer/implementing-ishellbrowser-host-ishellview-problem-drag-drop-help-26889992.html#r

---
改进(我终于明白了:))
----
您不需要实现IDropTarget,因为从CreateViewObject获得的IShellView已经实现了,只是出于某种原因而没有注册.因此,您所要做的就是得到它:

...
IShellView* view;
...
// CreateViewObject, CreateViewWindow etc.
...
HWND listViewWnd;
...
// Find the actual ListView 
...
IDropTarget* dt;
HRESULT hr = view->QueryInterface(IID_IDropTarget, (void**)&dt);
if(SUCCEEDED(hr))
{
   RevokeDragDrop(listViewWnd); // just in case
   RegisterDragDrop(listViewWnd, dt);
}
...


I implemented an IShellBrowser to host an IShellView object. And I set the FWF_DESKTOP flag when I call IShellView::CreateViewWindow. After IShellView::UIActivate, the view window its created cannot accept user drop files on it, but can drag to other explorer Window. I tried to obtain an IDropTarget via IShellFolder::CreateViewObject, and RegisterDragDrop to the view window, it works. But when I drag file from explorer to it, no dragging image displayed(it seems like old style D&D), and I also can''t drag and drop items in same window. If I CreateViewWindow with FWF_NONE, all fine. But....why?

How can I make Drag & Drop work properly when I specify FWF_DESKTOP?

解决方案

Thing is, somehow, a drop target is not registered for the shell''s ListView if FWF_DESKTOP is set.
So first, implement IDropTarget in a class. Then you should find the underlying ListView and call RegisterDrapDrop using the ListView''s HWND and an instance of your class.
It''s also nice to look here, another guy''s been trying similar things:
http://us.generation-nt.com/answer/implementing-ishellbrowser-host-ishellview-problem-drag-drop-help-26889992.html#r

---
Improvement (I finally got it :))
----
You don''t need to implement IDropTarget, ''cause the IShellView you get from CreateViewObject already implements it, it''s just not registered for some reason. So all you have to do is get it:

...
IShellView* view;
...
// CreateViewObject, CreateViewWindow etc.
...
HWND listViewWnd;
...
// Find the actual ListView 
...
IDropTarget* dt;
HRESULT hr = view->QueryInterface(IID_IDropTarget, (void**)&dt);
if(SUCCEEDED(hr))
{
   RevokeDragDrop(listViewWnd); // just in case
   RegisterDragDrop(listViewWnd, dt);
}
...


这篇关于设置FWF_DESKTOP标志后,无法将文件拖放到IShellView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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