-------------------- 使用例 --------------------
■MyWinApp.h
class CMyWinApp : public CWinApp
{
// 省略
public:
COccManagerEx m_OccManagerEx; // OCCマネージャ
// 省略
}
■MyWinApp.cpp
BOOL CMyWinApp::InitInstance()
{
// 省略
// OLE ライブラリの初期化
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
// 拡張OCCマネージャをコンテナにセット
// AfxEnableControlContainer();
AfxEnableControlContainer( &m_OccManagerEx );
// 省略
return TRUE;
}
■MyDialog.h
class CMyDialog : public CDialog
{
// 省略
// インプリメンテーション
protected:
class CDocHostUIHandlerEx : public CDocHostUIHandler
{
public:
// Called by IE4/MSHTML when it is being used as a drop target
// to allow the host to supply an alternative IDropTarget
HRESULT STDMETHODCALLTYPE GetDropTarget(
/* [in] */ IDropTarget __RPC_FAR *pDropTarget,
/* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget)
{
return S_FALSE; // D&Dを受け付けないようにする
}
} m_DocHostUIHandler;
// 省略
};
■MyDialog.cpp
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: この位置に初期化の補足処理を追加してください
IWebBrowser2Ptr spWebBrowser = GetDlgItem(IDC_WEBBROWSER)->GetControlUnknown();
// DocHostUIHandlerの組み込み
m_DocHostUIHandler.SetShowContextMenu( FALSE );
m_DocHostUIHandler.SetFlags( DOCHOSTUIFLAG_SCROLL_NO | DOCHOSTUIFLAG_NO3DBORDER );
CWndEscape* pWnd = (CWndEscape*)GetDlgItem(IDC_WEBBROWSER);
COleControlSiteEx* pCtrlSite = (COleControlSiteEx*)pWnd->GetOleControlSite();
pCtrlSite->SetDocHostUIHandler( &m_DocHostUIHandler );
// 初回のナビゲート
CString strURL = _T("http://www.kanabo.net/")
spWebBrowser->Navigate2(&_variant_t(strURL), &_variant_t(), &_variant_t(), &_variant_t(), &_variant_t());
return TRUE; // コントロールにフォーカスを設定しないとき、戻り値は TRUE となります
// 例外: OCX プロパティ ページの戻り値は FALSE となります
}
-------------------- ライブラリ --------------------
■OccManagerEx.h
class COccManagerEx : public COccManager
{
public:
virtual COleControlSite* CreateSite(COleControlContainer* pCtrlCont);
};
■OccManagerEx.cpp
#include "OleControlSiteEx.h"
COleControlSite* COccManagerEx::CreateSite(COleControlContainer* pCtrlCont)
{
// advanced control container apps may want to override
return new COleControlSiteEx(pCtrlCont);
}
■COleControlSiteEx.h
#include "OccManagerEx.H"
#include <MSHTMHST.H>
class COleControlSiteEx : public COleControlSite
{
public:
COleControlSiteEx(COleControlContainer* pCtrlCont);
virtual ~COleControlSiteEx();
void SetDocHostUIHandler( IDocHostUIHandler* pDocHostUIHandler )
{
m_pDocHostUIHandler = pDocHostUIHandler;
}
private:
IDocHostUIHandler* m_pDocHostUIHandler;
public:
// Interface maps
BEGIN_INTERFACE_PART(DocHostUIHandler, IDocHostUIHandler)
INIT_INTERFACE_PART(COleControlSiteEx, DocHostUIHandler)
STDMETHOD(ShowContextMenu)(
DWORD dwID, POINT* pptPosition, IUnknown* pCommandTarget, IDispatch* pDispatchObjectHit);
STDMETHOD(GetHostInfo)(DOCHOSTUIINFO* pInfo);
STDMETHOD(ShowUI)(
DWORD dwID, IOleInPlaceActiveObject* pActiveObject, IOleCommandTarget* pCommandTarget,
IOleInPlaceFrame* pFrame, IOleInPlaceUIWindow* pDoc);
STDMETHOD(HideUI)();
STDMETHOD(UpdateUI)();
STDMETHOD(EnableModeless)(BOOL fEnable);
STDMETHOD(OnDocWindowActivate)(BOOL fActivate);
STDMETHOD(OnFrameWindowActivate)(BOOL fActivate);
STDMETHOD(ResizeBorder)(
LPCRECT prcBorder, IOleInPlaceUIWindow* pUIWindow, BOOL fFrameWindow);
STDMETHOD(TranslateAccelerator)(LPMSG lpMsg, const GUID* pguidCmdGroup, DWORD nCmdID);
STDMETHOD(GetOptionKeyPath)(BSTR* pbstrKey, DWORD dwReserved);
STDMETHOD(GetDropTarget)(IDropTarget* pDropTarget, IDropTarget** ppDropTarget);
STDMETHOD(GetExternal)(IDispatch** ppDispatch);
STDMETHOD(TranslateUrl)(DWORD dwTranslate, OLECHAR* pchURLIn, OLECHAR** ppchURLOut);
STDMETHOD(FilterDataObject)(IDataObject* pDO, IDataObject** ppDORet);
END_INTERFACE_PART(DocHostUIHandler)
DECLARE_INTERFACE_MAP()
};
■COleControlSiteEx.cpp
COleControlSiteEx::COleControlSiteEx(COleControlContainer* pCtrlCont) : COleControlSite(pCtrlCont)
{
m_pDocHostUIHandler = NULL;
}
COleControlSiteEx::~COleControlSiteEx()
{
}
BEGIN_INTERFACE_MAP(COleControlSiteEx, COleControlSite)
INTERFACE_PART(COleControlSiteEx, IID_IDocHostUIHandler, DocHostUIHandler)
END_INTERFACE_MAP()
IMPLEMENT_IUNKNOWN(COleControlSiteEx, DocHostUIHandler)
HRESULT COleControlSiteEx::XDocHostUIHandler::ShowContextMenu(
DWORD dwID, POINT* pptPosition, IUnknown* pCommandTarget, IDispatch* pDispatchObjectHit)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->ShowContextMenu(
dwID, pptPosition, pCommandTarget, pDispatchObjectHit);
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::GetHostInfo(DOCHOSTUIINFO* pInfo)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->GetHostInfo(pInfo);
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::ShowUI(
DWORD dwID, IOleInPlaceActiveObject* pActiveObject, IOleCommandTarget* pCommandTarget,
IOleInPlaceFrame* pFrame, IOleInPlaceUIWindow* pDoc)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->ShowUI(
dwID, pActiveObject, pCommandTarget, pFrame, pDoc);
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::HideUI()
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->HideUI();
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::UpdateUI()
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->UpdateUI();
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::EnableModeless(BOOL fEnable)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->EnableModeless( fEnable );
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::OnDocWindowActivate(BOOL fActivate)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->OnDocWindowActivate( fActivate );
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::OnFrameWindowActivate(BOOL fActivate)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->OnFrameWindowActivate( fActivate );
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::ResizeBorder(
LPCRECT prcBorder, IOleInPlaceUIWindow* pUIWindow, BOOL fFrameWindow)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->ResizeBorder(
prcBorder, pUIWindow, fFrameWindow);
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::TranslateAccelerator(
LPMSG lpMsg, const GUID* pguidCmdGroup, DWORD nCmdID)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->TranslateAccelerator(
lpMsg, pguidCmdGroup, nCmdID);
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::GetOptionKeyPath(BSTR* pbstrKey, DWORD dwReserved)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->GetOptionKeyPath(pbstrKey, dwReserved);
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::GetDropTarget(
IDropTarget* pDropTarget, IDropTarget** ppDropTarget)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->GetDropTarget(pDropTarget, ppDropTarget);
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::GetExternal(IDispatch** ppDispatch)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->GetExternal(ppDispatch );
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::TranslateUrl(
DWORD dwTranslate, OLECHAR* pchURLIn, OLECHAR** ppchURLOut)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->TranslateUrl(dwTranslate, pchURLIn, ppchURLOut);
return( hResult );
}
return( E_NOTIMPL );
}
HRESULT COleControlSiteEx::XDocHostUIHandler::FilterDataObject(
IDataObject* pDO, IDataObject** ppDORet)
{
METHOD_PROLOGUE_EX(COleControlSiteEx, DocHostUIHandler)
if( pThis->m_pDocHostUIHandler != NULL )
{
HRESULT hResult = pThis->m_pDocHostUIHandler->FilterDataObject(pDO, ppDORet);
return( hResult );
}
return( E_NOTIMPL );
}
■DocHostUIHandler.h
class CDocHostUIHandler : public IDocHostUIHandler
{
// コンストラクション
public:
CDocHostUIHandler();
// アトリビュート
public:
BOOL GetShowContextMenu() { return(m_bShowContextMenu); }
void SetShowContextMenu( BOOL bShowContextMenu ) { m_bShowContextMenu = bShowContextMenu; }
UINT GetContextMenuID() { return(m_ContextMenuID); }
void SetContextMenuID( UINT ContextMenuID ) { m_ContextMenuID = ContextMenuID; }
int GetContextMenuPos() { return( m_ContextMenuPos ); }
void SetContextMenuPos( int ContextMenuPos ) { m_ContextMenuPos = ContextMenuPos; }
DWORD GetFlags() { return(m_dwFlags); }
void SetFlags( DWORD dwFlags ) { m_dwFlags = dwFlags; }
DWORD GetDoubleClick() { return(m_dwDoubleClick); }
void SetDoubleClick( DWORD dwDoubleClick ) { m_dwDoubleClick = dwDoubleClick; }
LPDISPATCH GetDispatch() { return(m_pDispatch); }
void SetDispatch( LPDISPATCH pDispatch ) { m_pDispatch = pDispatch; }
//protected:
BOOL m_bShowContextMenu;
UINT m_ContextMenuID;
int m_ContextMenuPos;
DWORD m_dwFlags;
DWORD m_dwDoubleClick;
LPDISPATCH m_pDispatch;
// オペレーション
public:
// オーバーライド
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef( void);
virtual ULONG STDMETHODCALLTYPE Release( void);
virtual HRESULT STDMETHODCALLTYPE ShowContextMenu(
/* [in] */ DWORD dwID,
/* [in] */ POINT __RPC_FAR *ppt,
/* [in] */ IUnknown __RPC_FAR *pcmdtReserved,
/* [in] */ IDispatch __RPC_FAR *pdispReserved);
virtual HRESULT STDMETHODCALLTYPE GetHostInfo(
/* [out][in] */ DOCHOSTUIINFO __RPC_FAR *pInfo);
virtual HRESULT STDMETHODCALLTYPE ShowUI(
/* [in] */ DWORD dwID,
/* [in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject,
/* [in] */ IOleCommandTarget __RPC_FAR *pCommandTarget,
/* [in] */ IOleInPlaceFrame __RPC_FAR *pFrame,
/* [in] */ IOleInPlaceUIWindow __RPC_FAR *pDoc);
virtual HRESULT STDMETHODCALLTYPE HideUI( void);
virtual HRESULT STDMETHODCALLTYPE UpdateUI( void);
virtual HRESULT STDMETHODCALLTYPE EnableModeless(
/* [in] */ BOOL fEnable);
virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate(
/* [in] */ BOOL fActivate);
virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate(
/* [in] */ BOOL fActivate);
virtual HRESULT STDMETHODCALLTYPE ResizeBorder(
/* [in] */ LPCRECT prcBorder,
/* [in] */ IOleInPlaceUIWindow __RPC_FAR *pUIWindow,
/* [in] */ BOOL fRameWindow);
virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(
/* [in] */ LPMSG lpMsg,
/* [in] */ const GUID __RPC_FAR *pguidCmdGroup,
/* [in] */ DWORD nCmdID);
virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath(
/* [out] */ LPOLESTR __RPC_FAR *pchKey,
/* [in] */ DWORD dw);
virtual HRESULT STDMETHODCALLTYPE GetDropTarget(
/* [in] */ IDropTarget __RPC_FAR *pDropTarget,
/* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget);
virtual HRESULT STDMETHODCALLTYPE GetExternal(
/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
virtual HRESULT STDMETHODCALLTYPE TranslateUrl(
/* [in] */ DWORD dwTranslate,
/* [in] */ OLECHAR __RPC_FAR *pchURLIn,
/* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);
virtual HRESULT STDMETHODCALLTYPE FilterDataObject(
/* [in] */ IDataObject __RPC_FAR *pDO,
/* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet);
// インプリメンテーション
public:
virtual ~CDocHostUIHandler();
};
■DocHostUIHandler.cpp
CDocHostUIHandler::CDocHostUIHandler()
{
m_bShowContextMenu = TRUE;
m_ContextMenuID = 0;
m_ContextMenuPos = 0;
m_dwFlags = 0;
m_dwDoubleClick = 0;
m_pDispatch = NULL;
}
CDocHostUIHandler::~CDocHostUIHandler()
{
if( m_pDispatch != NULL )
{
// m_pDispatch->Release();
m_pDispatch = NULL;
}
}
/////////////////////////////////////////////////////////////////////////////
// CDocHostUIHandler
ULONG CDocHostUIHandler::AddRef()
{
// ASSERT(0);
return( 1 );
}
ULONG CDocHostUIHandler::Release()
{
// ASSERT(0);
return( 0 );
}
HRESULT CDocHostUIHandler::QueryInterface(REFIID /*iid*/, LPVOID* /*ppvObj*/)
{
// ASSERT(0);
return( E_NOTIMPL );
}
HRESULT CDocHostUIHandler::ShowContextMenu(
DWORD /*dwID*/, POINT* pptPosition, IUnknown* /*pCommandTarget*/,
IDispatch* /*pDispatchObjectHit*/)
{
if (pptPosition == NULL)
return E_POINTER;
if( m_bShowContextMenu == TRUE )
{
return( S_FALSE ); // コンテキストメニューを表示する
}
/*
// 独自のコンテキストメニューを表示する
if( m_ContextMenuID != 0 )
{
::ShowContextMenu(AfxGetMainWnd(), m_ContextMenuID, m_ContextMenuPos, pptPosition);
}
*/
return( S_OK ); // コンテキストメニューを表示しない
}
// Called at initialisation to find UI styles from container
HRESULT CDocHostUIHandler::GetHostInfo(DOCHOSTUIINFO* pInfo)
{
if (pInfo == NULL)
return E_POINTER;
pInfo->cbSize = sizeof(DOCHOSTUIINFO);
pInfo->dwFlags = m_dwFlags;
pInfo->dwDoubleClick = m_dwDoubleClick;
return( S_OK );
}
// Allows the host to replace the IE4/MSHTML menus and toolbars.
HRESULT CDocHostUIHandler::ShowUI(
DWORD /*dwID*/, IOleInPlaceActiveObject* /*pActiveObject*/,
IOleCommandTarget* /*pCommandTarget*/, IOleInPlaceFrame* /*pFrame*/,
IOleInPlaceUIWindow* /*pDoc*/)
{
return( E_NOTIMPL );
}
// Called when IE4/MSHTML removes its menus and toolbars.
HRESULT CDocHostUIHandler::HideUI()
{
return( E_NOTIMPL );
}
// Notifies the host that the command state has changed.
HRESULT CDocHostUIHandler::UpdateUI()
{
return( E_NOTIMPL );
}
// Called from the IE4/MSHTML implementation of IOleInPlaceActiveObject::EnableModeless
HRESULT CDocHostUIHandler::EnableModeless(BOOL /*fEnable*/)
{
return( E_NOTIMPL );
}
// Called from the IE4/MSHTML implementation of IOleInPlaceActiveObject::OnDocWindowActivate
HRESULT CDocHostUIHandler::OnDocWindowActivate(BOOL /*fActivate*/)
{
return( E_NOTIMPL );
}
// Called from the IE4/MSHTML implementation of IOleInPlaceActiveObject::OnFrameWindowActivate.
HRESULT CDocHostUIHandler::OnFrameWindowActivate(BOOL /*fActivate*/)
{
return( E_NOTIMPL );
}
// Called from the IE4/MSHTML implementation of IOleInPlaceActiveObject::ResizeBorder.
HRESULT CDocHostUIHandler::ResizeBorder(
LPCRECT /*prcBorder*/, IOleInPlaceUIWindow* /*pUIWindow*/, BOOL /*fFrameWindow*/)
{
return( E_NOTIMPL );
}
// Called by IE4/MSHTML when IOleInPlaceActiveObject::TranslateAccelerator or IOleControlSite::TranslateAccelerator is called.
HRESULT CDocHostUIHandler::TranslateAccelerator(
LPMSG /*lpMsg*/, const GUID* /*pguidCmdGroup*/, DWORD /*nCmdID*/)
{
return( E_NOTIMPL );
}
// Returns the registry key under which IE4/MSHTML stores user preferences.
// Returns S_OK if successful, or S_FALSE otherwise.
// If S_FALSE, IE4/MSHTML will default to its own user options.
HRESULT CDocHostUIHandler::GetOptionKeyPath(BSTR* /*pbstrKey*/, DWORD /*dwReserved*/)
{
/*
HRESULT hr = S_FALSE;
if (pbstrKey == NULL)
return E_POINTER;
*pbstrKey = NULL;
if (m_spIDocHostUIHandlerDispatch != NULL)
{
hr = m_spIDocHostUIHandlerDispatch->GetOptionKeyPath(pbstrKey, dwReserved);
if (FAILED(hr) || *pbstrKey == NULL)
hr = S_FALSE;
}
else
{
if (m_bstrOptionKeyPath.m_str != NULL)
{
*pbstrKey = m_bstrOptionKeyPath.Copy();
hr = S_OK;
}
}
return hr;
*/
return( E_NOTIMPL );
}
// Called by IE4/MSHTML when it is being used as a drop target
// to allow the host to supply an alternative IDropTarget
HRESULT CDocHostUIHandler::GetDropTarget(
IDropTarget* /*pDropTarget*/, IDropTarget** /*ppDropTarget*/)
{
// if( ppDropTarget == NULL )
// return( E_POINTER );
return( E_NOTIMPL );
}
// Called by IE4/MSHTML to obtain the host's IDispatch interface
HRESULT CDocHostUIHandler::GetExternal(IDispatch** ppDispatch)
{
if (ppDispatch == NULL)
return( E_POINTER );
if( m_pDispatch == NULL )
return( E_NOTIMPL );
*ppDispatch = m_pDispatch;
(*ppDispatch)->AddRef();
return( S_OK );
}
// Called by IE4/MSHTML to allow the host an opportunity to modify the URL to be loaded
HRESULT CDocHostUIHandler::TranslateUrl(
DWORD /*dwTranslate*/, OLECHAR* /*pchURLIn*/, OLECHAR** /*ppchURLOut*/)
{
/*
HRESULT hr = S_FALSE;
if (ppchURLOut == NULL)
return E_POINTER;
*ppchURLOut = NULL;
if (m_spIDocHostUIHandlerDispatch != NULL)
{
CComBSTR bstrURLOut;
hr = m_spIDocHostUIHandlerDispatch->TranslateUrl(dwTranslate, CComBSTR(pchURLIn), &bstrURLOut);
if (SUCCEEDED(hr) && bstrURLOut.m_str != NULL)
{
UINT nLen = (bstrURLOut.Length() + 1) * 2;
*ppchURLOut = (OLECHAR*) CoTaskMemAlloc(nLen);
if (*ppchURLOut == NULL)
return E_OUTOFMEMORY;
memcpy(*ppchURLOut, bstrURLOut.m_str, nLen);
}
else
hr = S_FALSE;
}
return hr;
*/
return( E_NOTIMPL );
}
// Called on the host by IE4/MSHTML to allow the host to replace IE4/MSHTML's data object.
// This allows the host to block certain clipboard formats or support additional clipboard formats.
HRESULT CDocHostUIHandler::FilterDataObject(IDataObject* /*pDO*/, IDataObject** /*ppDORet*/)
{
/*
HRESULT hr = S_FALSE;
if (ppDORet == NULL)
return E_POINTER;
*ppDORet = NULL;
if (m_spIDocHostUIHandlerDispatch != NULL)
{
CComPtr<IUnknown> spUnk;
hr = m_spIDocHostUIHandlerDispatch->FilterDataObject(pDO, &spUnk);
if (spUnk)
hr = QueryInterface(IID_IDataObject, (void**)ppDORet);
if (FAILED(hr) || *ppDORet == NULL)
hr = S_FALSE;
}
return hr;
*/
return( E_NOTIMPL );
}
■CWndEscape.h
class CWndEscape : public CWnd
{
public:
COleControlContainer* GetOleControlContainer() { return( m_pCtrlCont ); }
void SetOleControlContainer( COleControlContainer* pCtrlCont ) { m_pCtrlCont = pCtrlCont; }
COleControlSite* GetOleControlSite() { return( m_pCtrlSite ); }
void SetOleControlSite( COleControlSite* pCtrlSite ) { m_pCtrlSite = pCtrlSite; }
};