Failed miserably at external functions

This commit is contained in:
andreja6
2018-07-06 22:38:27 -07:00
parent 03fd38aaa7
commit dae6dd5390
5 changed files with 61 additions and 4 deletions

1
Demo.h
View File

@@ -5,6 +5,7 @@
class Demo { // : public GApp { class Demo { // : public GApp {
public: public:
Demo(const GAppSettings& settings,HWND parentWindow); Demo(const GAppSettings& settings,HWND parentWindow);
void Boop();
virtual ~Demo() {} virtual ~Demo() {}
virtual void exitApplication(); virtual void exitApplication();
virtual void onInit(); virtual void onInit();

View File

@@ -256,6 +256,10 @@
RelativePath=".\Globals.cpp" RelativePath=".\Globals.cpp"
> >
</File> </File>
<File
RelativePath=".\IEDispatcher.cpp"
>
</File>
<File <File
RelativePath="main.cpp" RelativePath="main.cpp"
> >
@@ -341,6 +345,10 @@
RelativePath=".\Globals.h" RelativePath=".\Globals.h"
> >
</File> </File>
<File
RelativePath=".\IEDispatcher.h"
>
</File>
<File <File
RelativePath=".\resource.h" RelativePath=".\resource.h"
> >

9
IEDispatcher.cpp Normal file
View File

@@ -0,0 +1,9 @@
#include "IEDispatcher.h"
IEDispatcher::IEDispatcher(void)
{
}
IEDispatcher::~IEDispatcher(void)
{
}

13
IEDispatcher.h Normal file
View File

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

View File

@@ -16,6 +16,7 @@
#define _WIN32_WINNT 0x0400 #define _WIN32_WINNT 0x0400
#include <G3DAll.h> #include <G3DAll.h>
#include <initguid.h>
#include <iomanip> #include <iomanip>
#include "Instance.h" #include "Instance.h"
#include "resource.h" #include "resource.h"
@@ -37,6 +38,7 @@
#include <comdef.h> #include <comdef.h>
#include <comdefsp.h> #include <comdefsp.h>
#include "ax.h" #include "ax.h"
#include "IEDispatcher.h"
#if G3D_VER < 61000 #if G3D_VER < 61000
@@ -44,6 +46,18 @@
#endif #endif
HWND hwnd; 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; IWebBrowser2* test;
static std::string title = ""; static std::string title = "";
static DataModelInstance* dataModel; static DataModelInstance* dataModel;
@@ -86,7 +100,7 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
0, 0,
560, 560,
800, 800,
50, 60,
_hWndMain, // parent _hWndMain, // parent
NULL, // menu NULL, // menu
hThisInstance, hThisInstance,
@@ -1340,6 +1354,14 @@ App::~App() {
} }
*/ */
void Boop()
{
OnError(1, "Test");
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); 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) LRESULT CALLBACK ToolboxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA);
MessageBox(NULL, (LPCSTR)wParam, (LPCSTR)lParam, 1);
if (app==NULL) if (app==NULL)
{ {
return DefWindowProc(hwnd, msg, wParam, lParam); return DefWindowProc(hwnd, msg, wParam, lParam);
@@ -1392,6 +1415,7 @@ LRESULT CALLBACK ToolboxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} }
return 0; return 0;
} }
LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA);
@@ -1543,8 +1567,8 @@ void Demo::resizeWithParent(HWND parentWindow)
{ {
RECT rect; RECT rect;
GetClientRect(parentWindow,&rect); GetClientRect(parentWindow,&rect);
SetWindowPos(_hwndRenderer,NULL,0,0,rect.right,rect.bottom-50,SWP_NOMOVE); SetWindowPos(_hwndRenderer,NULL,0,0,rect.right,rect.bottom-60,SWP_NOMOVE);
SetWindowPos(_hwndToolbox,NULL,0,rect.bottom-50,rect.right,50,SWP_NOACTIVATE | SWP_SHOWWINDOW); SetWindowPos(_hwndToolbox,NULL,0,rect.bottom-60,rect.right,60,SWP_NOACTIVATE | SWP_SHOWWINDOW);
GetClientRect(_hwndRenderer,&rect); GetClientRect(_hwndRenderer,&rect);
int viewWidth=rect.right; int viewWidth=rect.right;
int viewHeight=rect.bottom; int viewHeight=rect.bottom;
@@ -1568,7 +1592,9 @@ void Demo::onCreate(HWND parentWindow)
int main(int argc, char** argv) { int main(int argc, char** argv) {
try{ 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()) if (!AXRegister())
return 0; return 0;