class ATL_NO_VTABLE CHtmCtrlHost : public CAxHostWindow { public: DECLARE_NOT_AGGREGATABLE(CHtmCtrlHost); DECLARE_WND_CLASS(_T("CHtmCtrlHost")) BEGIN_COM_MAP(CHtmCtrlHost) COM_INTERFACE_ENTRY2(IDispatch, IAxWinAmbientDispatchEx) COM_INTERFACE_ENTRY(IAxWinHostWindow) COM_INTERFACE_ENTRY(IAxWinHostWindowLic) COM_INTERFACE_ENTRY(IOleClientSite) COM_INTERFACE_ENTRY(IOleInPlaceSiteWindowless) COM_INTERFACE_ENTRY(IOleInPlaceSiteEx) COM_INTERFACE_ENTRY(IOleInPlaceSite) COM_INTERFACE_ENTRY(IOleWindow) COM_INTERFACE_ENTRY(IOleControlSite) COM_INTERFACE_ENTRY(IOleContainer) COM_INTERFACE_ENTRY(IObjectWithSite) COM_INTERFACE_ENTRY(IServiceProvider) COM_INTERFACE_ENTRY(IAxWinAmbientDispatchEx) COM_INTERFACE_ENTRY(IAxWinAmbientDispatch) COM_INTERFACE_ENTRY(IDocHostUIHandler) COM_INTERFACE_ENTRY(IAdviseSink) END_COM_MAP() virtual void OnFinalMessage(HWND hWnd) { FinalRelease(); GetControllingUnknown()->Release(); } STDMETHOD(GetHostInfo)(DOCHOSTUIINFO* pInfo) { HRESULT hr; hr = __super::GetHostInfo(pInfo); pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_SCROLL_NO; //去掉3D边框滚动条 return hr; } static HRESULT CreateIeControl(HWND hWnd, RECT *pRect, IUnknown **ppControl) { HRESULT hr; _bstr_t bStrClsid; CLSID Clsid; BSTR pClsId; CComPtr<IUnknown> spUnkContainer; CComPtr<IAxWinHostWindow> spAxWindow; CAxWindow2T<CWindow> Wnd; AtlAxWinInit(); // Clsid = __uuidof(InternetExplorer); // Clsid = __uuidof(IWebBrowser2); Clsid = CLSID_WebBrowser; // bStrClsid = "{8856F961-340A-11D0-A96B-00C04FD705A2}"; StringFromCLSID(CLSID_WebBrowser, &pClsId); bStrClsid = pClsId; CoTaskMemFree(pClsId); Wnd.Create(hWnd, pRect, NULL, WS_CHILD|WS_VISIBLE); hr = _CreatorClass::CreateInstance(NULL, __uuidof(IUnknown), (void**)&spUnkContainer); if(FAILED(hr)) return hr; hr = spUnkContainer->QueryInterface(IID_IAxWinHostWindow, (void**)&spAxWindow); if(FAILED(hr)) return hr; hr = spAxWindow->CreateControl(bStrClsid, Wnd.m_hWnd, NULL); if(FAILED(hr)) return hr; hr = spAxWindow->QueryControl(__uuidof(IUnknown), (void**)ppControl); if(FAILED(hr)) return hr; return hr; } };