Override of WebBrowserSite IDocHostUIHandler using WebBrowser.CreateWebBrowserSiteBase doesn't work

D

Don Walker

According to http://msdn2.microsoft.com/en-us/library/system.windows.forms.
webbrowser.createwebbrowsersitebase.aspx I should be able to customize the
behavior of the System.Windows.Forms.WebBrowser control as follows:

"To use this feature, implement classes that inherit from the WebBrowser and
WebBrowser.WebBrowserSite classes. The unmanaged WebBrowser ActiveX control
uses the protected CreateWebBrowserSiteBase method to retrieve extensibility
interfaces implemented by the WebBrowser.WebBrowserSite class. Override the
CreateWebBrowserSiteBase method to return an instance of your own class that
inherits from the WebBrowser.WebBrowserSite class. The WebBrowser.
WebBrowserSite class provides default implementations of the OLE
IDocHostUIHandler. You can provide your own implementation of this interface
or implement any other WebBrowser ActiveX control interface in order to
customize the behavior of the control. If you provide your own
implementation for any IDocHostUIHandler members, you must implement all the
members of that interface."

I've implemented my own classes and confirmed in debug that my version of
CreateWebBrowserSiteBase is being called and creates my class. However, none
of my IDocHostUIHandler methods are being called. I suspect that the problem
may be in my constructor, which calls the WebBrowser.WebBrowserSite
constructor, which creates a competing implementation of IDocHostUIHandler.

The documentation implies that this should work. Am I missing anything? Any
suggestions or workarounds?

Thanks.
 
E

elucent

I ran into the same problem. The IDocHostUIHandler implementation is
NOT being called in my extended WebBrowserSite class. If using the
reflection, you can find out the extended class has 2 IDocHostUIHandler
interfaces. One is apparently from WebBrowserSite base class in the
System.Windows.Forms.UnSafeNativeMethods namespace, and the other is my
new implementation.

Any suggestion or progress on overriding the IDocHostUIHandler in the
base class?
 
C

Charles Law

Hi Don

I have just answered a related question in the
microsoft.public.dotnet.languages.vb newsgroup.

Have a look at the thread "webbrowser control border" starting 22 Feb 2006
and see if this answers your question.

HTH

Charles
 
E

elucent

Charles,

Thanks for sharing your answer here. I understand that I can implement
IDocHostUIHandler in the form or usercontrol where hosts the WebBrowser
net control. However, I need to extend the WebBrowser class to keep it
reusable without much of overheads. And MSDN clearly states that
WebBrowser is extensible thru WebBrowserSite class where i can
implement IDocHostUIHandler as well as other interfaces. While
implementing other interfaces turns out successfully, IDocHostUIHandler
yet has conflicts with the base class. Hopefully someone else will have
the answer soon.

Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top