PRB: WebBrowser Control Clients Share Global Settings

ID: Q183412


The information in this article applies to:


SYMPTOMS

All hosts of the WebBrowser control share the same global Internet settings.

Commercial WebBrowser control hosts such as the America Online (AOL) browser are affected by this behavior. For example, specifying a default home page for AOL in AOL's WWW preferences will set the same default home page for both AOL and Internet Explorer (IE), even when IE is used separately from AOL.

The third-party products discussed here are manufactured by vendors independent of Microsoft; we make no warranty, implied or otherwise, regarding these products' performance or reliability.


RESOLUTION

For most of the global Internet settings, there is no supported method for automatically saving a set of properties for each WebBrowser host.

However, certain download options, such as whether to download ActiveX controls or not, can be overridden and specified on a per-host basis.


STATUS

This behavior is by design.


MORE INFORMATION

As documented in the Internet Client SDK (InetSDK), WebBrowser hosts can implement the DISPID_AMBIENT_DLCONTROL ambient property on their default dispatch interface to override the global settings for download options.

The WALKALL sample in the InetSDK (\InetSDK\Samples\Walkall) demonstrates this technique for an MSHTML host. A similar method can be used in WebBrowser hosts to achieve the same effect.

MSHTML will also ask for a new user agent via DISPID_AMBIENT_USERAGENT when navigating to clicked hyperlinks. This ambient property can be overridden, but it is not used when programmatically calling the Navigate method.

An MFC host of the WebBrowser control can easily affect these ambient properties by overriding the OnAmbientProperty method of the hosting CWnd- based class:


BOOL CWBHostView::OnAmbientProperty(COleControlSite* pSite,
                                    DISPID dispid, VARIANT* pvar)
{
   // Change download properties - no java, no scripts...
   if (dispid == DISPID_AMBIENT_DLCONTROL)
   {
      pvar->vt = VT_I4;
      pvar->lVal = DLCTL_NO_SCRIPTS | DLCTL_NO_JAVA
                 | DLCTL_NO_RUNACTIVEXCTLS | DLCTL_NO_DLACTIVEXCTLS;

      return TRUE;
   }

   // Change user agent for this web browser host during hyperlinks
   if (dispid == DISPID_AMBIENT_USERAGENT)
   {
      CString strUserAgent("MyWebBrowserHost");

      pvar->vt = VT_BSTR;
      pvar->bstr = (BSTR)strUserAgent;

      return TRUE;
   }

   return CView::OnAmbientProperty(pSite, dispid, pvar);
} 
The DISPID_AMBIENT_* and DLCTL_* values are defined in Mshtmdid.h (\InetSDK\Include\MSHTMDID.H).


REFERENCES

For more information, please see the MSDN Web Workshop:

http://msdn.microsoft.com/workshop/default.asp

Additional query words: AOL CompuServe WebBrowser UserAgent


Keywords          : kb3rdparty kbIE500 AXSDKWebBrowser 
Version           : WINDOWS:1.0,3.0,3.01,3.02,4.0,4.01
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: April 30, 1999