diff --git a/IEBrowser.cpp b/IEBrowser.cpp index 9e6b557..9902814 100644 --- a/IEBrowser.cpp +++ b/IEBrowser.cpp @@ -2,11 +2,13 @@ #define WIN32_LEAN_AND_MEAN #endif + #include #include "IEBrowser.h" #include "Globals.h" #include "ax.h" +//#include "IEDispatcher.h" void IEBrowser::Boop(char* test) { @@ -36,6 +38,12 @@ IEBrowser::~IEBrowser(void) { } } +// Something goes here +int IEBrowser::setExternal(IDispatch** ext) +{ + return 1; +} + bool IEBrowser::navigateSyncURL(wchar_t* url) { MSG messages; @@ -52,10 +60,39 @@ bool IEBrowser::navigateSyncURL(wchar_t* url) DispatchMessage(&messages); } } + Sleep(30); + HRESULT hresult = webBrowser->get_Document(&spDocument); - if (&spDocument!=0) + if (SUCCEEDED(hresult) && (spDocument != 0)) { + + IOleObject* spOleObject; + if (SUCCEEDED(spDocument->QueryInterface(IID_IOleObject,(void**)&spOleObject))) + { + IOleClientSite* spClientSite; + hresult = spOleObject->GetClientSite(&spClientSite); + if (SUCCEEDED(hresult) && spClientSite) + { + m_spDefaultDocHostUIHandler = spClientSite; + ICustomDoc* spCustomDoc; + + //IEDispatcher* spIEDispatcher; + if (SUCCEEDED(m_spDefaultDocHostUIHandler->QueryInterface(IID_IDocHostUIHandler,(void**)&m_spHandler))) + { + if (SUCCEEDED(spDocument->QueryInterface(IID_ICustomDoc,(void**)&spCustomDoc))) + { + spCustomDoc->SetUIHandler(m_spHandler); + + m_spHandler->GetExternal(&m_spExternal); + + } + } + } + } + + + return true; } } @@ -65,4 +102,4 @@ bool IEBrowser::navigateSyncURL(wchar_t* url) MessageBox(NULL,"Cannot read IWebBrowser2...",(Globals::PlaceholderName+" Crash").c_str(),MB_OK); } return false; -} \ No newline at end of file +} diff --git a/IEBrowser.h b/IEBrowser.h index 4ee5587..3f86ba6 100644 --- a/IEBrowser.h +++ b/IEBrowser.h @@ -2,7 +2,7 @@ #pragma once #include #include -//#include +#include class IEBrowser { public: @@ -14,4 +14,10 @@ class IEBrowser { IWebBrowser2* webBrowser; HWND hwnd; IDispatch* spDocument; + IHTMLDocument* spDocument2; + IDocHostUIHandler* m_spHandler; + IDispatch* m_spExternal; + IDispatch* m_newExternal; + IOleClientSite* m_spDefaultDocHostUIHandler; + int setExternal(IDispatch** ext); }; diff --git a/IEDispatcher.cpp b/IEDispatcher.cpp index 10330f6..ff1b132 100644 --- a/IEDispatcher.cpp +++ b/IEDispatcher.cpp @@ -33,7 +33,6 @@ HRESULT STDMETHODCALLTYPE IEDispatcher::GetIDsOfNames(const IID &, LPOLESTR *, U return NULL; } HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *) - { return NULL; } diff --git a/IEDispatcher.h b/IEDispatcher.h index 9cc1e41..4b16fd2 100644 --- a/IEDispatcher.h +++ b/IEDispatcher.h @@ -1,8 +1,19 @@ #pragma once #include "oaidl.h" +//DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F); +/* class IEDispatcher : public IDispatch { +*/ + +EXTERN_C const IID IID_IDispatch; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("B323F8E0-2E68-11D0-90EA-00AA0060F86F") + IEDispatcher : public IDispatch + { public: IEDispatcher(void); ~IEDispatcher(void); @@ -15,3 +26,5 @@ public: HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *); }; + +#endif diff --git a/main.cpp b/main.cpp index d2be410..f260bec 100644 --- a/main.cpp +++ b/main.cpp @@ -13,6 +13,7 @@ // TODO: Move toolbar buttons with resized window. + #define _WIN32_WINNT 0x0400 #include @@ -46,8 +47,6 @@ #endif HWND hwnd; - -DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F); HRESULT hresult; OLECHAR dat = ((OLECHAR)"SayHello"); OLECHAR * szMember = &dat; @@ -1321,16 +1320,6 @@ void Demo::onKeyPressed(int key) dataModel->getOpen(); } } - #ifdef _DEBUG - if (key==VK_ADD) - { - dataModel->modXMLLevel(1); - } - if (key==VK_SUBTRACT) - { - dataModel->modXMLLevel(-1); - } - #endif } void Demo::onKeyUp(int key) {