问题
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.
来源:https://stackoverflow.com/questions/20066447/webbrowser-idroptarget