如何从IDragData获取OnDrageEnter事件中的文件内容?

时间:2019-03-06 09:46:17

标签: cefsharp

在CefSharp的winforms实现中,我实现了IDragHandler。

在OnDragEnter事件中,我想要获取文件内容。

当前我正在使用

Dim st As IO.Stream = Nothing
Dim i As Integer = dragData.GetFileContents(st)

没有数据写入流。

您能从从外部(例如桌面)拖动到浏览器的文件中获取文件内容吗?

我认为这是一个上游问题,但是,如果我拖动一个选定的Outlook项目,则dragData没有文件或文件名,但是IsFragment为true,而FragmentText包含有关电子邮件的一般信息,例如主题。这是上游问题吧?

1 个答案:

答案 0 :(得分:1)

Adding my comment to the answer please see Issue 322605: Drag and Drop support for E-Mails from Microsoft Outlook.

To be complete I wanted to add how I solved this until Chromium catches up. I am hosting my CEFSharp winforms instance in a WPF window. When the CefSharp OnDragEnter event fires I open an almost transparent popup directly under the mouse pointer. This popup has the drag events for WPF enabled and once they fire and give me the dragged contents i close the popup. It is a little but tricky as the OnDragEnter event from CefSharp fires once the popup is gone but otherwise I can find out what is being dragged.