User wtx_sonery wants to know whether it is possible to style the webbrowser control with the rest of the application. The answer is yes, you can implement IDocHostUIHandler’s GetHostInfo method and return DOCHOSTUIFLAG_THEME in the host flags.
IDocHostUIHandler is already implemented in MFC and ATL. For MFC there are CHtmlControlSite and CBrowserControlSite but you should be overriding the GetHostInfo function in CHTMLView and CDHTMLDialog. In ATL the template definition is in Atliface.h but you need to derive from IDocHostUIHandlerDispatch by yourself.
Implementing IDocHostUIHandler Windows Forms gets a little tricky. Windows Forms already implemented it on its WebBrowserSite class but you can’t extend it. Following the .Net Framework Class Library Security Guideline the Windows Forms version of the IDocHostUIHandler interface is internal to the class library. If you derive from WebBrowserSite and implement your own version of IDocHostUIHandler, you still get Windows Forms’s implementation of IDocHostUIHandler when you do QueryInterface on the browser site. That means you need to get ride of the Windows Forms wrapper of the webbrowser control and provide your own hosting implementation.
WPF/Silverlight users, you are out of luck. The stock version of the webbrowser control does not even provide a way to customize the host site. The best thing you can do is to see if Windows Forms interop is available to the platform and if so, embed a csexwb Windows Forms control. There are some unsolved problems in the csexwb discussion area, however.
There are other switches you can tweak the browser control’s behavior. However there is only one bit available in the enum for future flags. Maybe that’s why IE introduces feature control in IE6 for Windows XP SP2 where features are based on enum – you get a 4GB range for new features!
Leave a Reply