From dae6dd53907520cb9ee976e97b6731eccc53194f Mon Sep 17 00:00:00 2001 From: andreja6 Date: Fri, 6 Jul 2018 22:38:27 -0700 Subject: [PATCH] Failed miserably at external functions --- Demo.h | 1 + G3DTest.vcproj | 8 ++++++++ IEDispatcher.cpp | 9 +++++++++ IEDispatcher.h | 13 +++++++++++++ main.cpp | 34 ++++++++++++++++++++++++++++++---- 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 IEDispatcher.cpp create mode 100644 IEDispatcher.h diff --git a/Demo.h b/Demo.h index 1227a4e..7496586 100644 --- a/Demo.h +++ b/Demo.h @@ -5,6 +5,7 @@ class Demo { // : public GApp { public: Demo(const GAppSettings& settings,HWND parentWindow); + void Boop(); virtual ~Demo() {} virtual void exitApplication(); virtual void onInit(); diff --git a/G3DTest.vcproj b/G3DTest.vcproj index c2dff5b..277651e 100644 --- a/G3DTest.vcproj +++ b/G3DTest.vcproj @@ -256,6 +256,10 @@ RelativePath=".\Globals.cpp" > + + @@ -341,6 +345,10 @@ RelativePath=".\Globals.h" > + + diff --git a/IEDispatcher.cpp b/IEDispatcher.cpp new file mode 100644 index 0000000..bb2069c --- /dev/null +++ b/IEDispatcher.cpp @@ -0,0 +1,9 @@ +#include "IEDispatcher.h" + +IEDispatcher::IEDispatcher(void) +{ +} + +IEDispatcher::~IEDispatcher(void) +{ +} diff --git a/IEDispatcher.h b/IEDispatcher.h new file mode 100644 index 0000000..b736138 --- /dev/null +++ b/IEDispatcher.h @@ -0,0 +1,13 @@ +#pragma once +#include "oaidl.h" + +class IEDispatcher : public IDispatch +{ +public: + IEDispatcher(void); + ~IEDispatcher(void); + int IEDispatcher::QueryInterface(const IID &riid, void **ppvObject); + ULONG IEDispatcher::AddRef(); + HRESULT IEDispatcher::GetIDsOfNames(const IID &rrid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); + ULONG IEDispatcher::Release(); +}; diff --git a/main.cpp b/main.cpp index aa2e5b0..fba380d 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,7 @@ #define _WIN32_WINNT 0x0400 #include +#include #include #include "Instance.h" #include "resource.h" @@ -37,6 +38,7 @@ #include #include #include "ax.h" +#include "IEDispatcher.h" #if G3D_VER < 61000 @@ -44,6 +46,18 @@ #endif HWND hwnd; +DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F); +HRESULT hresult; +IUnknown * punk; +IDispatch * pdisp = new IEDispatcher(); +OLECHAR dat = ((OLECHAR)"SayHello"); +OLECHAR * szMember = &dat; +DISPID dispid; +DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; +EXCEPINFO excepinfo; +UINT nArgErr; + + IWebBrowser2* test; static std::string title = ""; static DataModelInstance* dataModel; @@ -86,7 +100,7 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w 0, 560, 800, - 50, + 60, _hWndMain, // parent NULL, // menu hThisInstance, @@ -1340,6 +1354,14 @@ App::~App() { } */ +void Boop() +{ + OnError(1, "Test"); +} + + + + LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); @@ -1377,6 +1399,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK ToolboxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); + MessageBox(NULL, (LPCSTR)wParam, (LPCSTR)lParam, 1); if (app==NULL) { return DefWindowProc(hwnd, msg, wParam, lParam); @@ -1392,6 +1415,7 @@ LRESULT CALLBACK ToolboxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } return 0; } + LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); @@ -1543,8 +1567,8 @@ void Demo::resizeWithParent(HWND parentWindow) { RECT rect; GetClientRect(parentWindow,&rect); - SetWindowPos(_hwndRenderer,NULL,0,0,rect.right,rect.bottom-50,SWP_NOMOVE); - SetWindowPos(_hwndToolbox,NULL,0,rect.bottom-50,rect.right,50,SWP_NOACTIVATE | SWP_SHOWWINDOW); + SetWindowPos(_hwndRenderer,NULL,0,0,rect.right,rect.bottom-60,SWP_NOMOVE); + SetWindowPos(_hwndToolbox,NULL,0,rect.bottom-60,rect.right,60,SWP_NOACTIVATE | SWP_SHOWWINDOW); GetClientRect(_hwndRenderer,&rect); int viewWidth=rect.right; int viewHeight=rect.bottom; @@ -1568,7 +1592,9 @@ void Demo::onCreate(HWND parentWindow) int main(int argc, char** argv) { try{ - OleInitialize(0); + hresult = OleInitialize(NULL); + hresult = CoCreateInstance(CLSID_G3d, NULL, CLSCTX_SERVER, IID_IUnknown, (void **)&punk); + hresult = punk->QueryInterface(IID_IDispatch, &pdisp); if (!AXRegister()) return 0;