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!

-Mark

Here is the event handler for NavComplete2:

void CLaunchboardDlg::OnNavigateComplete2(LPDISPATCH pDisp, VARIANT FAR*
URL)
{
 TRACE("NavComplete2\n");
 // recommended location to get doc and set host ui handler
 HRESULT hr;
 // 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);
    }

Quote:
}

And here is the ATL COM class implementation:

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

BEGIN_COM_MAP(CDocHostUi)
    COM_INTERFACE_ENTRY(IDocHostUIHandler)
END_COM_MAP()

public:
   STDMETHOD(ShowContextMenu)( DWORD dwID, POINT FAR *ppt, IUnknown FAR
*pcmdTarget,
    IDispatch FAR *pdispObject )
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::ResizeBorder"));
   }
   STDMETHOD(GetHostInfo)(DOCHOSTUIINFO FAR *pInfo)
   {
   ATLTRACE(_T("IDocHostUIHandler::GetHostInfo"));

   pInfo->cbSize  = sizeof(DOCHOSTUIINFO);
   // pInfo->dwFlags = m_dwDocHostUIFlags;
   // Turn off the 3-D border and scrollbar.
   pInfo->dwFlags |= DOCHOSTUIFLAG_NO3DBORDER|DOCHOSTUIFLAG_SCROLL_NO;
   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::ShowUI"));
   }
   STDMETHOD(HideUI)(void)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::HideUI"));
   }
   STDMETHOD(UpdateUI)(void)
   {
   // ATLTRACENOTIMPL(_T("IDocHostUIHandler::UpdateUI"));
    return S_OK; // S_FALSE;
   }
   STDMETHOD(EnableModeless)(BOOL fEnable)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::EnableModeless"));
   }
   STDMETHOD(OnDocWindowActivate)(BOOL fActivate)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::OnDocWindowActivate"));
   }
   STDMETHOD(OnFrameWindowActivate)(BOOL fActivate)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::OnFrameWindowActivate"));
   }
   STDMETHOD(ResizeBorder)(LPCRECT prcBorder, IOleInPlaceUIWindow FAR*
pUIWindow,
         BOOL fRameWindow)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::ResizeBorder"));
   }
   STDMETHOD(TranslateAccelerator)(LPMSG lpMsg,
           const GUID FAR* pguidCmdGroup,
           DWORD nCmdID)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::TranslateAccelerator\n"));
   }
   STDMETHOD(GetOptionKeyPath)(LPOLESTR FAR* pchKey, DWORD dw)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::GetOptionKeyPath"));
   }
   STDMETHOD(GetDropTarget)(IDropTarget* pDropTarget, IDropTarget**
ppDropTarget)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::GetDropTarget"));
   }
   STDMETHOD(GetExternal)(IDispatch** ppDispatch)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::GetExternal"));
   }
   STDMETHOD(TranslateUrl)(DWORD dwTranslate, OLECHAR* pchURLIn,
         OLECHAR** ppchURLOut)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::TranslateUrl"));
   }
   STDMETHOD(FilterDataObject)(IDataObject* pDO, IDataObject** ppDORet)
   {
   ATLTRACENOTIMPL(_T("IDocHostUIHandler::FilterDataObject"));
   }
   // *********** end IDocHostUIHandler

Quote:
};

For ATL spport, lines added elsewhere:

In stdafx.h

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

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

// 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
 _Module.Init(NULL,NULL);



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