RE: WebBrowser and IDocHostUIHandler::GetDropTarget



Here's the solution MS Support eventually came up with:

Drop handlers for the WebBrowser are registered in two places. Shdocvw
registers a handler for the "Shell Embedding" window (see Spy++ to see the
window hierarchy). MSHTML registers a handler for the "Internet
Explorer_Server" window.

The IDropTarget we get in IDocHostUIHandler::GetDropTarget's first parameter
is MSHTML's. This interface doesn't do much. The one we want is Shdocvw's
handler. This can be retrieved through IServiceProvider as follows:

IServiceProvider* pSP;
m_browser.GetControlUnknown()->QueryInterface(IID_IServiceProvider,
(void**)&pSP);

IDropTarget* pDT;
pSP->QueryService(SID_STopLevelBrowser, IID_IDropTarget, (void**)&pDT);

Delegating drop calls to pDT results in the expected WebBrowser drop.

Thanks to Igor Tandetnik for looking into this as well.

--Don


"Don Huff" wrote:

> My goal is to add support for custom drag/drop formats to a WebBrowser while
> preserving the browser's current drag/drop support. I have implemented
> IDocHostUIHandler on the control site (similar to Q236312) and provided my
> implementation of IDropTarget. The DragEnter/Over/Leave and Drop methods are
> called. I can now easily add support for my custom drop formats.
>
> However, I have lost support for the original drop formats (i.e. dropped
> file from Windows Explorer). The first parameter to
> IDocHostUIHandler::GetDropTarget is a "Pointer to an IDropTarget interface
> for the current drop target object supplied by MSHTML." That's the extent of
> the documentation. Seems logical that I can AddRef this interface and
> delegate unhandled drops to it in order to maintain original drag/drop
> behavior. Problem is, any calls to this interface result in the drop effect
> set to DROPEFFECT_NONE and no action when calling Drop(...).
>
> Any thoughts how to maintain the browser's current drop support? Failing
> that, any suggestions what data formats I should support to get a reasonable
> replacement for the default drop support?
>
> Thanks,
>
> Don Huff
>
> P.S.
> Apologies for the cross-post. I didn't get any replies in the MSDN managed
> newsgroups, and there are a number of WebBrowser-focused groups.
>
.



Relevant Pages

  • RE: hide cursor for kiosk application (powerpoint)
    ... you use a WebBrowser control to display ... PowerPoint document and you'd like to hide the cursor on the WebBrowser. ... I watch the messages of the paneClassDC "Slide Show" window. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: hide cursor for kiosk application (powerpoint)
    ... PowerPoint document and you'd like to hide the cursor on the WebBrowser. ... I watch the messages of the paneClassDC "Slide Show" window. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: WebBrowser not displaying page in Mobile application
    ... WebBrowser displays the temp file immediately. ... Microsoft Managed Newsgroup Support Team ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.general)
  • Re: What control to use???
    ... recommended to use WebBrowser on your form. ... 'HTML Viewer ActiveX Control' ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • RE: WebBrowser Problems in Thread
    ... webbrowser control and launch webbrowser activities in a startmethod. ... I set up a Windows application project and create a usercontrol. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)