views:

256

answers:

1

I've a webbrowser control and I'm trying implement IDocHostUIHandler in the container. However since I don't have a default IOleClientSite I can't forward all events to a default container.

And I couldn't find a way to response all of them, giving wrong responses to some of the events or not doing anything causing application to crash.

Fox example:

Public Sub ShowUI(ByVal dwID As UInteger, ByRef pActiveObject As Object, ByRef pCommandTarget As Object, ByRef pFrame As Object, ByRef pDoc As Object) Implements SecureBrowser.IDocHostUIHandler.ShowUI
    'DefaultClientSite.ShowUI(dwID, pActiveObject, pCommandTarget, pFrame, pDoc)
End Sub

Since I'm not in IE or something like that I don't have a default IOleClientSite. MSDN doesn't help that much when it comes to figure out how to fill those pointers/ByRefs.

A: 

I haven't actually done this for the IDocHostUIHanlder interface, but in general, it's usually enough to return E_NOTIMPL for any methods that you don't want to implement.

If you've got a version of Visual Studio with the MFC source, you can have a look at their implementation, in CHtmlView: that largely just returns S_FALSE for most methods, without setting any of the output structures.

DavidK
So basically returning E_NOTIMPL will force the COM to use the default settings. Am I getting this right? Because that sounds good :)
dr. evil
That is the theory, and it usually works for the extension interfaces that Microsoft provides. However, it is up to the caller (here IE) to notice you've returned E_NOTIMPL and do what's appropriate. I would suggest start with trying E_NOTIMPL and if that fails, investigate doing what MFC does (mostly returning S_FALSE).
DavidK