WebBrowser: IDropTarget

2019-07-16 14:01发布

问题:

I am looking for an example how to implement IDropTarget within WebBrowser. As a 'base' code I will be using this answer.

回答1:

In theory, you should wrap the original IDropTarget object, passed from MSHTML to you at IDocHostUIHandler::GetDropTarget, and return your own implementation of IDropTarget, which would forward all IDropTarget methods to that original object, with one exception: IDropTarget::DragEnter.

In your implementation of IDropTarget::DragEnter, you would check the IDataObject object which contains the data about to be dropped (IDataObject::EnumFormatEtc) and return DROPEFFECT_NONE if the data is not acceptable, otherwise forward it too.

I don't have a ready-to-use code sample for this. Feel free to experiment and post your own answer when you get there.