BUG: IDocHostUIHandler2 Is Not Called from Within a WebBrowser Control

Article translations Article translations
Article ID: 272968
This article was previously published under Q272968
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

Symptoms

Internet Explorer 5.5 introduces the IDocHostUIHandler2 interface, which is derived from IDocHostUIHandler, to override the user preferences in Microsoft's HTML parsing and rendering engine (MSHTML). However, if a WebBrowser control is hosted, IDocHostUIHandler2 is not queried, and the host cannot override user preferences.

Cause

This problem occurs because of a bug in the WebBrowser control that shipped with Internet Explorer 5.5.

Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

More information

Steps to Reproduce Behavior

  1. Download the MSDN Driller sample from the following Microsoft Web site:
    http://msdn.microsoft.com/Downloads/samples/Internet/browser/driller/sample.asp
  2. Extend this sample by the IDocHostUIHandler2 interface. Add the following code to the Custsite.h file:
    BEGIN_INTERFACE_PART(DocHostUIHandler2, IDocHostUIHandler2)
    	 STDMETHOD(GetOverrideKeyPath)(
    			/* [out] */ LPOLESTR __RPC_FAR *pchKey,
                /* [in] */ DWORD dw);
    	STDMETHOD(ShowContextMenu)(/* [in] */ DWORD dwID,
                /* [in] */ POINT __RPC_FAR *ppt,
                /* [in] */ IUnknown __RPC_FAR *pcmdtReserved,
                /* [in] */ IDispatch __RPC_FAR *pdispReserved);
    	STDMETHOD(GetHostInfo)( 
                /* [out][in] */ DOCHOSTUIINFO __RPC_FAR *pInfo);
    	STDMETHOD(ShowUI)( 
                /* [in] */ DWORD dwID,
                /* [in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject,
                /* [in] */ IOleCommandTarget __RPC_FAR *pCommandTarget,
                /* [in] */ IOleInPlaceFrame __RPC_FAR *pFrame,
                /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pDoc);
    	STDMETHOD(HideUI)(void);
    	STDMETHOD(UpdateUI)(void);
    	STDMETHOD(EnableModeless)(/* [in] */ BOOL fEnable);
    	STDMETHOD(OnDocWindowActivate)(/* [in] */ BOOL fEnable);
    	STDMETHOD(OnFrameWindowActivate)(/* [in] */ BOOL fEnable);
    	STDMETHOD(ResizeBorder)( 
                /* [in] */ LPCRECT prcBorder,
                /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pUIWindow,
                /* [in] */ BOOL fRameWindow);
    	STDMETHOD(TranslateAccelerator)( 
                /* [in] */ LPMSG lpMsg,
                /* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
                /* [in] */ DWORD nCmdID);
    	STDMETHOD(GetOptionKeyPath)( 
                /* [out] */ LPOLESTR __RPC_FAR *pchKey,
                /* [in] */ DWORD dw);
    	STDMETHOD(GetDropTarget)(
                /* [in] */ IDropTarget __RPC_FAR *pDropTarget,
                /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget);
            STDMETHOD(GetExternal)( 
                /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
            STDMETHOD(TranslateUrl)( 
                /* [in] */ DWORD dwTranslate,
                /* [in] */ OLECHAR __RPC_FAR *pchURLIn,
                /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);
            STDMETHOD(FilterDataObject)( 
                /* [in] */ IDataObject __RPC_FAR *pDO,
                /* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet);
    END_INTERFACE_PART(DocHostUIHandler2)
    					
  3. In the Custsite.cpp file, add the following code:
    // **************************************************************************
    // * IDocHostUIHandler2 methods
    // **************************************************************************
    ULONG FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::AddRef()
    {
    METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
    return pThis->ExternalAddRef();
    }
    
    ULONG FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::Release()
    {                            
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return pThis->ExternalRelease();
    }
    
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::QueryInterface
    (REFIID riid, void **ppvObj)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            HRESULT hr = (HRESULT)pThis->ExternalQueryInterface(&riid, ppvObj);
            return hr;
    }
    
    // CImpIDocHostUIHandler2::GetHostInfo
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::GetHostInfo
    ( DOCHOSTUIINFO* pInfo )
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER;
            pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
            return S_OK;
    }
    
    // CImpIDocHostUIHandler2::ShowUI
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::ShowUI(
    				DWORD dwID, 
    				IOleInPlaceActiveObject * /*pActiveObject*/,
    				IOleCommandTarget * pCommandTarget,
    				IOleInPlaceFrame * /*pFrame*/,
    				IOleInPlaceUIWindow * /*pDoc*/)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return S_OK;
    }
    
    // CImpIDocHostUIHandler2::HideUI
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::HideUI(void)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return S_OK;
    }
    
    // CImpIDocHostUIHandler2::UpdateUI
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::UpdateUI(void)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return S_OK;
    }
    
    // CImpIDocHostUIHandler2::EnableModeless
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::EnableModeless
    (BOOL /*fEnable*/)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return E_NOTIMPL;
    }
    
    // CImpIDocHostUIHandler2::OnDocWindowActivate
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::OnDocWindowActivate
    (BOOL /*fActivate*/)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return E_NOTIMPL;
    }
    
    // CImpIDocHostUIHandler2::OnFrameWindowActivate
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::OnFrameWindowActivate
    (BOOL /*fActivate*/)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return E_NOTIMPL;
    }
    
    // CImpIDocHostUIHandler2::ResizeBorder
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::ResizeBorder(
    				LPCRECT /*prcBorder*/, 
    				IOleInPlaceUIWindow* /*pUIWindow*/,
    				BOOL /*fRameWindow*/)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return E_NOTIMPL;
    }
    
    // CImpIDocHostUIHandler2::ShowContextMenu
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::ShowContextMenu(
    				DWORD /*dwID*/, 
    				POINT* /*pptPosition*/,
    				IUnknown* /*pCommandTarget*/,
    				IDispatch* /*pDispatchObjectHit*/)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return S_FALSE;
    }
    
    // CImpIDocHostUIHandler2::TranslateAccelerator
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::TranslateAccelerator(LPMSG lpMsg,
                /* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
                /* [in] */ DWORD nCmdID)
    {
            METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
            return S_FALSE;
    }
    
    // CImpIDocHostUIHandler2::GetOptionKeyPath
    HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler2::GetOptionKeyPath
    (BSTR* pbstrKey, DWORD)
    {
    
    	METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
    	return E_NOTIMPL;
    }
    
    STDMETHODIMP CCustomControlSite::XDocHostUIHandler2::GetDropTarget( 
                /* [in] */ IDropTarget __RPC_FAR *pDropTarget,
                /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget)
    {
    
    	METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
    	return E_NOTIMPL;
    }
    
    STDMETHODIMP CCustomControlSite::XDocHostUIHandler2::GetExternal( 
                /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch)
    {
            // Return the IDispatch that you have to extend the object model.
            IDispatch* pDisp = (IDispatch*)theApp.m_pDispOM;<BR/>
            pDisp->AddRef();
            *ppDispatch = pDisp;
            return S_OK;
    }
            
    STDMETHODIMP CCustomControlSite::XDocHostUIHandler2::TranslateUrl( 
                /* [in] */ DWORD dwTranslate,
                /* [in] */ OLECHAR __RPC_FAR *pchURLIn,
                /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut)
    {
    	METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
    	return E_NOTIMPL;
    }
            
    STDMETHODIMP CCustomControlSite::XDocHostUIHandler2::FilterDataObject( 
                /* [in] */ IDataObject __RPC_FAR *pDO,
                /* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet)
    {
    	METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
    	return E_NOTIMPL;
    }
    
    STDMETHODIMP CCustomControlSite::XDocHostUIHandler2::GetOverrideKeyPath(
        LPOLESTR *pchKey, DWORD dw)
    {
    	/*
    	 * This is not called due to the bug.
    	 */	
    	METHOD_PROLOGUE(CCustomControlSite, DocHostUIHandler2)
    	return E_NOTIMPL;
    }
    					
  4. Download the Internet Explorer 5.5 Headers and Libraries from the following Microsoft Web site:
    http://msdn.microsoft.com/downloads/samples/internet/libraries/ie55_lib/sample.asp
  5. Set up the project development environment so that the Internet Explorer 5.5 Headers and Libraries are at the beginning of the search path. To do this, follow these steps:
    1. In Visual Studio Integrated Development Environment (IDE), on the Tools menu, click Options.
    2. On the Directories tab, under Include files, insert your Internet Explorer 5.5 Header files folder. Under Library files, insert your Internet Explorer 5.5 Library files folder. Move both entries to the beginning of the list.
  6. Compile the project to create a debug version executable.
  7. Set the break point inside the CCustomControlSite::XDocHostUIHandler2::GetOverrideKeyPath function, and press F5 to debug. The break point does not get hit.

References

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
http://msdn.microsoft.com/ie/

http://support.microsoft.com/iep

Properties

Article ID: 272968 - Last Review: October 26, 2013 - Revision: 6.0
Keywords: 
kbnosurvey kbarchive kbbug kbmshtml kbpending kbwebbrowser KB272968

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com