IEView::IEView(HWND _parent, HTMLBuilder *_builder, int x, int y, int cx, int cy) { MSG msg; parent = _parent; builder = _builder; rcClient.left = x; rcClient.top = y; rcClient.right = x + cx; rcClient.bottom = y + cy; if (SUCCEEDED(pWebBrowser.CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC))) { CComPtr<IOleObject> pOleObject; if (SUCCEEDED(pWebBrowser.QueryInterface(&pOleObject))) { pOleObject->SetClientSite(this); pOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, this->parent, &rcClient); } else MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK); CComPtr<IOleInPlaceObject> pOleInPlace; if (SUCCEEDED(pWebBrowser.QueryInterface(&pOleInPlace))) pOleInPlace->GetWindow(&hwnd); else MessageBox(NULL, TranslateT("IID_IOleInPlaceObject failed."), TranslateT("RESULT"), MB_OK); setBorder(); CComPtr<IConnectionPointContainer> pCPContainer; // Step 1: Get a pointer to the connection point container. if (SUCCEEDED(pWebBrowser.QueryInterface(&pCPContainer))) { // m_pConnectionPoint is defined like this: // Step 2: Find the connection point. if (SUCCEEDED(pCPContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &m_pConnectionPoint))) { // Step 3: Advise the connection point that you // want to sink its events. sink = new IEViewSink(this); if (FAILED(m_pConnectionPoint->Advise(sink, &m_dwCookie))) MessageBox(NULL, TranslateT("Failed to Advise"), TranslateT("C++ Event Sink"), MB_OK); } } setMainWndProc((WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)IEViewWindowProcedure)); } { mir_cslock lck(mutex); next = list; if (next != NULL) next->prev = this; list = this; } pWebBrowser->put_RegisterAsDropTarget(VARIANT_FALSE); }
IEEmbed::IEEmbed(HWND _parent) { MSG msg; parent = _parent; GetClientRect(_parent, &rcClient); if (SUCCEEDED(pWebBrowser.CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC))) { CComPtr<IOleObject> pOleObject; if (SUCCEEDED(pWebBrowser.QueryInterface(&pOleObject))) { pOleObject->SetClientSite(this); pOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, this->parent, &rcClient); } else MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK); CComPtr<IOleInPlaceObject> pOleInPlace; if (SUCCEEDED(pWebBrowser.QueryInterface(&pOleInPlace))) pOleInPlace->GetWindow(&hwnd); else MessageBox(NULL, TranslateT("IID_IOleInPlaceObject failed."), TranslateT("RESULT"), MB_OK); //setBorder(); CComPtr<IConnectionPointContainer> pCPContainer; // Step 1: Get a pointer to the connection point container. if (SUCCEEDED(pWebBrowser.QueryInterface(&pCPContainer))) { // m_pConnectionPoint is defined like this: // Step 2: Find the connection point. if (SUCCEEDED(pCPContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &m_pConnectionPoint))) { // Step 3: Advise the connection point that you // want to sink its events. sink = new IEEmbedSink(this); if (FAILED(m_pConnectionPoint->Advise(sink, &m_dwCookie))) MessageBox(NULL, TranslateT("Failed to Advise"), TranslateT("C++ Event Sink"), MB_OK); } } setMainWndProc((WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)IEEmbedWindowProcedure)); SetFocus(hwnd); } pWebBrowser->put_RegisterAsDropTarget(VARIANT_FALSE); }
IEView::IEView(HWND parent, HTMLBuilder* builder, int x, int y, int cx, int cy) { MSG msg; IOleObject* pOleObject = NULL; IOleInPlaceObject *pOleInPlace; this->parent = parent; this->builder = builder; // this->smileyWindow = NULL; prev = next = NULL; hwnd = NULL; sink = NULL; pWebBrowser = NULL; m_pConnectionPoint = NULL; m_cRef = 0; selectedText = NULL; getFocus = false; clearRequired = true; #ifdef GECKO if (SUCCEEDED(CoCreateInstance(CLSID_MozillaBrowser, NULL, CLSCTX_INPROC, IID_IWebBrowser2, (LPVOID*)&pWebBrowser))) { #else if (SUCCEEDED(CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IWebBrowser2, (LPVOID*)&pWebBrowser))) { #endif // pWebBrowser->put_RegisterAsBrowser(VARIANT_FALSE); if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleObject, (void**)&pOleObject))) { rcClient.left = x; rcClient.top = y; rcClient.right = x + cx; rcClient.bottom = y + cy; pOleObject->SetClientSite(this); pOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, parent, &rcClient); pOleObject->Release(); } else { MessageBoxA(NULL,"IID_IOleObject failed.","RESULT",MB_OK); } if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleInPlaceObject, (void**)&pOleInPlace))) { pOleInPlace->GetWindow(&hwnd); pOleInPlace->Release(); } else { MessageBoxA(NULL,"IID_IOleInPlaceObject failed.","RESULT",MB_OK); } LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); style |= (WS_EX_STATICEDGE); // style &= ~(WS_EX_ACCEPTFILES); SetWindowLong(hwnd,GWL_EXSTYLE,style); IConnectionPointContainer* pCPContainer; // Step 1: Get a pointer to the connection point container. if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPContainer))) { // m_pConnectionPoint is defined like this: // Step 2: Find the connection point. if (SUCCEEDED(pCPContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &m_pConnectionPoint))) { // Step 3: Advise the connection point that you // want to sink its events. sink = new IEViewSink(this); //#ifndef GECKO if (FAILED(m_pConnectionPoint->Advise((IUnknown *)sink, &m_dwCookie))) { MessageBoxA(NULL, "Failed to Advise", "C++ Event Sink", MB_OK); } //#endif } pCPContainer->Release(); } //#ifndef GECKO setMainWndProc((WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG) IEViewWindowProcedure)); //#endif } EnterCriticalSection(&mutex); next = list; if (next != NULL) { next->prev = this; } list = this; LeaveCriticalSection(&mutex); // clear(); pWebBrowser->put_RegisterAsDropTarget(VARIANT_FALSE); } IEView::~IEView() { IOleObject* pOleObject = NULL; if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleObject, (void**)&pOleObject))) { pOleObject->SetClientSite(NULL); pOleObject->Release(); } else { MessageBoxA(NULL,"IID_IOleObject failed.","RESULT",MB_OK); } EnterCriticalSection(&mutex); if (list == this) { list = next; } else if (prev!=NULL) { prev->next = next; } if (next != NULL) { next->prev = prev; } LeaveCriticalSection(&mutex); if (builder != NULL) { delete builder; builder = NULL; } if (m_pConnectionPoint != NULL) { m_pConnectionPoint->Unadvise(m_dwCookie); m_pConnectionPoint->Release(); } if (sink != NULL) { delete sink; } if (selectedText != NULL) { delete selectedText; } pWebBrowser->Release(); DestroyWindow(hwnd); } void IEView::setMainWndProc(WNDPROC wndProc) { mainWndProc = wndProc; } WNDPROC IEView::getMainWndProc() { return mainWndProc; } void IEView::setDocWndProc(WNDPROC wndProc) { docWndProc = wndProc; } WNDPROC IEView::getDocWndProc() { return docWndProc; } void IEView::setServerWndProc(WNDPROC wndProc) { serverWndProc = wndProc; } WNDPROC IEView::getServerWndProc() { return serverWndProc; } // IUnknown STDMETHODIMP IEView::QueryInterface(REFIID riid, PVOID *ppv) { *ppv=NULL; if (IID_IUnknown==riid) *ppv=this; if (IID_IOleClientSite==riid) *ppv=(IOleClientSite*)this;//Unknown)m_pIOleClientSite; if (IID_IOleWindow==riid || IID_IOleInPlaceSite==riid) *ppv=(IOleInPlaceSite*)this;//m_pIOleIPSite; if (IID_IDocHostUIHandler==riid) *ppv=(IDocHostUIHandler*)this;//m_pIOleIPSite; if (NULL!=*ppv) { ((LPUNKNOWN)*ppv)->AddRef(); return NOERROR; } return E_NOINTERFACE; }
IEView::IEView(HWND parent, HTMLBuilder* builder, int x, int y, int cx, int cy) { MSG msg; IOleObject* pOleObject = NULL; IOleInPlaceObject *pOleInPlace; isContactSet = false; this->parent = parent; this->builder = builder; prev = next = NULL; hwnd = NULL; sink = NULL; pWebBrowser = NULL; m_pConnectionPoint = NULL; m_cRef = 0; selectedText = NULL; getFocus = false; rcClient.left = x; rcClient.top = y; rcClient.right = x + cx; rcClient.bottom = y + cy; if (SUCCEEDED(CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IWebBrowser2, (LPVOID*)&pWebBrowser))) { if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleObject, (void**)&pOleObject))) { pOleObject->SetClientSite(this); pOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, this->parent, &rcClient); pOleObject->Release(); } else { MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK); } if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleInPlaceObject, (void**)&pOleInPlace))) { pOleInPlace->GetWindow(&hwnd); pOleInPlace->Release(); } else { MessageBox(NULL, TranslateT("IID_IOleInPlaceObject failed."), TranslateT("RESULT"), MB_OK); } setBorder(); IConnectionPointContainer* pCPContainer; // Step 1: Get a pointer to the connection point container. if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPContainer))) { // m_pConnectionPoint is defined like this: // Step 2: Find the connection point. if (SUCCEEDED(pCPContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &m_pConnectionPoint))) { // Step 3: Advise the connection point that you // want to sink its events. sink = new IEViewSink(this); if (FAILED(m_pConnectionPoint->Advise((IUnknown *)sink, &m_dwCookie))) { MessageBox(NULL, TranslateT("Failed to Advise"), TranslateT("C++ Event Sink"), MB_OK); } } pCPContainer->Release(); } setMainWndProc((WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) IEViewWindowProcedure)); } { mir_cslock lck(mutex); next = list; if (next != NULL) next->prev = this; list = this; } pWebBrowser->put_RegisterAsDropTarget(VARIANT_FALSE); }