MFC dlg app, browser ctrl, ATL dochostui interface problem 
Author Message
 MFC dlg app, browser ctrl, ATL dochostui interface problem

   I have an MFC dialog app with a web browser control in the dialog.  I am
trying to turn off the context menu and disable the scroll bar, and so
implemented an IDocHostUIHandler interface.  On the controls NavComplete2
event, I create my ATL object and pass it in to ICustomDoc->SetUIHandler.
But I am not getting all the calls into my interface.  Really, if I could
just get the GetHostInfo() call I would be happy.
   All I see it doing is calling GetDropTarget() and then UpdateUI().  It
never calls GetHostInfo() or any of the others to start with.  When I click
on the control's scroll bar, then it calls a few others, but that's too
late, the window already has a scroll bar.
   Am I going about this the wrong way?  Any help is much appreciated.  Thx!


Here is the event handler for NavComplete2:

void CLaunchboardDlg::OnNavigateComplete2(LPDISPATCH pDisp, VARIANT FAR*
 // recommended location to get doc and set host ui handler
 // my com object
 CComObject<CDocHostUi> *pDocHostUi;
 hr = CComObject<CDocHostUi>::CreateInstance(&pDocHostUi);

    CComPtr<IDispatch> spDoc;
 // m_spWebBrowser->get_Document(&spDoc);
    spDoc = m_webBrowser.GetDocument();

    if (spDoc)
        CComQIPtr<ICustomDoc, &IID_ICustomDoc> spCustomDoc(spDoc);
        if (spCustomDoc)
            // spCustomDoc->SetUIHandler(this);
   hr = spCustomDoc->SetUIHandler((IDocHostUIHandler*)pDocHostUi);


And here is the ATL COM class implementation:

class /*ATL_NO_VTABLE*/ CDocHostUi :
 public CComObjectRootEx<CComSingleThreadModel>,
 public IDocHostUIHandler
   // DWORD m_dwDocHostUIFlags;
 { }


   STDMETHOD(ShowContextMenu)( DWORD dwID, POINT FAR *ppt, IUnknown FAR
    IDispatch FAR *pdispObject )

   pInfo->cbSize  = sizeof(DOCHOSTUIINFO);
   // pInfo->dwFlags = m_dwDocHostUIFlags;
   // Turn off the 3-D border and scrollbar.
   pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;

   return S_OK;
   STDMETHOD(ShowUI)(DWORD dwID, IOleInPlaceActiveObject FAR* pActiveObject,
     IOleCommandTarget FAR* pCommandTarget,
     IOleInPlaceFrame  FAR* pFrame,
     IOleInPlaceUIWindow FAR* pDoc)
   // ATLTRACENOTIMPL(_T("IDocHostUIHandler::UpdateUI"));
    return S_OK; // S_FALSE;
   STDMETHOD(EnableModeless)(BOOL fEnable)
   STDMETHOD(OnDocWindowActivate)(BOOL fActivate)
   STDMETHOD(OnFrameWindowActivate)(BOOL fActivate)
   STDMETHOD(ResizeBorder)(LPCRECT prcBorder, IOleInPlaceUIWindow FAR*
         BOOL fRameWindow)
   STDMETHOD(TranslateAccelerator)(LPMSG lpMsg,
           const GUID FAR* pguidCmdGroup,
           DWORD nCmdID)
   STDMETHOD(GetOptionKeyPath)(LPOLESTR FAR* pchKey, DWORD dw)
   STDMETHOD(GetDropTarget)(IDropTarget* pDropTarget, IDropTarget**
   STDMETHOD(GetExternal)(IDispatch** ppDispatch)
   STDMETHOD(TranslateUrl)(DWORD dwTranslate, OLECHAR* pchURLIn,
         OLECHAR** ppchURLOut)
   STDMETHOD(FilterDataObject)(IDataObject* pDO, IDataObject** ppDORet)
   // *********** end IDocHostUIHandler


For ATL spport, lines added elsewhere:

In stdafx.h

// #include <afxcmn.h>   // MFC support for Windows Common Controls

#include <afxdtctl.h>  // MFC support for Internet Explorer 4 Common
#include <afxcmn.h>   // MFC support for Windows Common Controls

// Add the includes here for ATL and atlimp.cpp since there is
// no ATL lib file.
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <atlimpl.cpp>

Aded in app's InitInstance()

 if (!AfxOleInit()) {
  AfxMessageBox("Could not initialize COM");
 // ATL Initialization

Mon, 08 Sep 2003 04:14:27 GMT  
 [ 1 post ] 

 Relevant Pages 

1. How to query interface from MFC ActiveX Dlg Ctrl

2. ATL or MFC - creating a non-trivial ActiveX ctrl that supports multiple interfaces

3. A problem about OnSize of MFC Dlg-Based App

4. Problems using an MFC/ATL Multithreaded COM Obj with an MFC app

5. MFC app with ATL object resource problem

6. Resource handle problem in MFC app with ATL object

7. NT Service MFC/ATL Problem when another app does SendMessage(BROADCAST)

8. problem in a dlg-based app

9. MFC Custom Ctrl to ATL ActiveX conversation?

10. Using MFC data exchange with ATL composite ctrls, is it possible

11. Q: Using MFC data exchange with ATL composite ctrls

12. SUBEDIT ATL Sample and CTRL-C and CTRL-V


Powered by phpBB® Forum Software