C++(MFC)中WebBrowser去除3D边框的方法(实现IDocHostUIHandler接口)
2010-11-09 12:59:14 来源:WEB开发网核心提示:先说实在的:最终解决办法是实现IDocHostUIHandler接口,在GetHostInfo方法里解决,C++(MFC)中WebBrowser去除3D边框的方法(实现IDocHostUIHandler接口),但“实现接口”意味着QueryInterface、AddRef、Release三个方法
先说实在的:最终解决办法是实现IDocHostUIHandler接口,在GetHostInfo方法里解决,但“实现接口”意味着QueryInterface、AddRef、Release三个方法必须实现,所以相关代码是:
class CMyWebBrowser : public IDocHostUIHandler { public: CMyWebBrowser() { m_cRef = 0; } virtual ~CMyWebBrowser() {} LONG m_cRef; private: HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) { HRESULT result = S_OK; if (IsBadWritePtr(ppvObject, sizeof(LPVOID))) result = E_INVALIDARG; if (result == S_OK) { *ppvObject = NULL; if ( IsEqualIID( riid, IID_IUnknown ) ) *ppvObject = this; // else if ( IsEqualIID( riid, IID_IOleClientSite ) ) // *ppvObject = (IOleClientSite *) this; else if ( IsEqualIID( riid, IID_IDocHostUIHandler ) ) *ppvObject = (IDocHostUIHandler *) this; else result = E_NOINTERFACE; } if (result == S_OK) this->AddRef(); return result; } ULONG STDMETHODCALLTYPE AddRef(){ InterlockedIncrement(&m_cRef); return m_cRef; } ULONG STDMETHODCALLTYPE Release() { ULONG ulRefCount = InterlockedDecrement(&m_cRef); return ulRefCount; } HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable) { return S_OK; } HRESULT STDMETHODCALLTYPE FilterDataObject(IDataObject *pDO,IDataObject **ppDORet){return S_OK;} HRESULT STDMETHODCALLTYPE GetDropTarget(IDropTarget *pDropTarget, IDropTarget **ppDropTarget){return S_OK;} HRESULT STDMETHODCALLTYPE GetExternal(IDispatch **ppDispatch){return S_OK;} HRESULT STDMETHODCALLTYPE GetOptionKeyPath(LPOLESTR *pchKey,DWORD dw){return S_OK;} STDMETHOD(GetHostInfo)(DOCHOSTUIINFO *pInfo) { pInfo->cbSize = sizeof(DOCHOSTUIINFO); pInfo->dwFlags |= DOCHOSTUIFLAG_NO3DBORDER; pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT; pInfo->pchHostCss = 0; pInfo->pchHostNS = 0; return S_OK; } HRESULT STDMETHODCALLTYPE HideUI(VOID){return S_OK;} HRESULT STDMETHODCALLTYPE OnDocWindowActivate(BOOL fActivate){return S_OK;} HRESULT STDMETHODCALLTYPE OnFrameWindowActivate(BOOL fActivate){return S_OK;} HRESULT STDMETHODCALLTYPE ResizeBorder(LPCRECT prcBorder,IOleInPlaceUIWindow *pUIWindow,BOOL fFrameWindow){return S_OK;} HRESULT STDMETHODCALLTYPE ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved,IDispatch *pdispReserved){return S_OK;} HRESULT STDMETHODCALLTYPE ShowUI(DWORD dwID, IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc ){return S_OK;} HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID ) {return S_OK;} HRESULT STDMETHODCALLTYPE TranslateUrl(DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut ) {return S_OK;} HRESULT STDMETHODCALLTYPE UpdateUI(VOID) {return S_OK;} };
Tags:C++(MFC) WebBrowser 3D边框 IDocHostUIHandler
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接