Click here to Skip to main content
15,887,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted

1 solution

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);
}
...
 
Share this answer
 
v3
Comments
Lighter Zhang 30-May-11 2:09am    
Thank you very much...It works!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900