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.