IEBrowser gets the external object. Nothing else.

This commit is contained in:
MusicalProgrammer
2019-11-02 14:51:44 -04:00
parent d8ba0dcfc8
commit 08d8dc4df0
5 changed files with 60 additions and 16 deletions

View File

@@ -2,11 +2,13 @@
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#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;
}
}

View File

@@ -2,7 +2,7 @@
#pragma once
#include <mshtml.h>
#include <exdisp.h>
//#include <Mshtmhst.h>
#include <Mshtmhst.h>
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);
};

View File

@@ -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;
}

View File

@@ -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

View File

@@ -13,6 +13,7 @@
// TODO: Move toolbar buttons with resized window.
#define _WIN32_WINNT 0x0400
#include <G3DAll.h>
@@ -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)
{