IEBrowser class added
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -51,3 +51,4 @@ log.txt
|
|||||||
G3DTest.suo
|
G3DTest.suo
|
||||||
G3DTest.suo
|
G3DTest.suo
|
||||||
stderr.txt
|
stderr.txt
|
||||||
|
desktop.ini
|
||||||
|
|||||||
1
Demo.h
1
Demo.h
@@ -29,6 +29,7 @@ class Demo { // : public GApp {
|
|||||||
void onMouseRightUp(int x, int y);
|
void onMouseRightUp(int x, int y);
|
||||||
void onMouseMoved(int x, int y);
|
void onMouseMoved(int x, int y);
|
||||||
void onMouseWheel(int x, int y, short delta);
|
void onMouseWheel(int x, int y, short delta);
|
||||||
|
|
||||||
CameraController cameraController;
|
CameraController cameraController;
|
||||||
RenderDevice* renderDevice;
|
RenderDevice* renderDevice;
|
||||||
UserInput* userInput;
|
UserInput* userInput;
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ int const Globals::patch = 2;
|
|||||||
int Globals::surfaceId = 2;
|
int Globals::surfaceId = 2;
|
||||||
bool Globals::showMouse = true;
|
bool Globals::showMouse = true;
|
||||||
bool Globals::useMousePoint = false;
|
bool Globals::useMousePoint = false;
|
||||||
|
|
||||||
|
const std::string Globals::PlaceholderName = "Dynamica";
|
||||||
|
|
||||||
|
|
||||||
G3D::TextureRef Globals::surface;
|
G3D::TextureRef Globals::surface;
|
||||||
POINT Globals::mousepoint;
|
POINT Globals::mousepoint;
|
||||||
Globals::Globals(void){}
|
Globals::Globals(void){}
|
||||||
|
|||||||
@@ -17,4 +17,5 @@ public:
|
|||||||
static const int patch;
|
static const int patch;
|
||||||
static G3D::TextureRef surface;
|
static G3D::TextureRef surface;
|
||||||
static int surfaceId;
|
static int surfaceId;
|
||||||
};
|
static const std::string PlaceholderName;
|
||||||
|
};
|
||||||
|
|||||||
65
IEBrowser.cpp
Normal file
65
IEBrowser.cpp
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "IEBrowser.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
#include "ax.h"
|
||||||
|
|
||||||
|
|
||||||
|
IEBrowser::IEBrowser(HWND attachHWnd) {
|
||||||
|
MSG messages;
|
||||||
|
while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE))
|
||||||
|
{
|
||||||
|
if (IsDialogMessage(hwnd, &messages) == 0)
|
||||||
|
{
|
||||||
|
TranslateMessage(&messages);
|
||||||
|
DispatchMessage(&messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hwnd = attachHWnd;
|
||||||
|
spDocument = 0;
|
||||||
|
webBrowser = 0;
|
||||||
|
SendMessage(hwnd,AX_INPLACE,1,0);
|
||||||
|
SendMessage(hwnd,AX_QUERYINTERFACE,(WPARAM)&IID_IWebBrowser2,(LPARAM)&webBrowser);
|
||||||
|
}
|
||||||
|
|
||||||
|
IEBrowser::~IEBrowser(void) {
|
||||||
|
if (webBrowser)
|
||||||
|
{
|
||||||
|
webBrowser->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IEBrowser::navigateSyncURL(wchar_t* url)
|
||||||
|
{
|
||||||
|
MSG messages;
|
||||||
|
if (webBrowser)
|
||||||
|
{
|
||||||
|
webBrowser->Navigate(url,0,0,0,0);
|
||||||
|
for (int i=1;i<1000;i++)
|
||||||
|
{
|
||||||
|
while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE))
|
||||||
|
{
|
||||||
|
if (IsDialogMessage(hwnd, &messages) == 0)
|
||||||
|
{
|
||||||
|
TranslateMessage(&messages);
|
||||||
|
DispatchMessage(&messages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sleep(30);
|
||||||
|
HRESULT hresult = webBrowser->get_Document(&spDocument);
|
||||||
|
if (&spDocument!=0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox(NULL,"Cannot read IWebBrowser2...",Globals::PlaceholderName.c_str(),MB_OK);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
15
IEBrowser.h
Normal file
15
IEBrowser.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
//#include "WindowFunctions.h"
|
||||||
|
#include <mshtml.h>
|
||||||
|
#include <exdisp.h>
|
||||||
|
//#include <Mshtmhst.h>
|
||||||
|
|
||||||
|
class IEBrowser {
|
||||||
|
public:
|
||||||
|
IEBrowser(HWND attachHWnd);
|
||||||
|
~IEBrowser(void);
|
||||||
|
bool navigateSyncURL(wchar_t* url);
|
||||||
|
private:
|
||||||
|
IWebBrowser2* webBrowser;
|
||||||
|
HWND hwnd;
|
||||||
|
IDispatch* spDocument;
|
||||||
|
};
|
||||||
@@ -7,3 +7,34 @@ IEDispatcher::IEDispatcher(void)
|
|||||||
IEDispatcher::~IEDispatcher(void)
|
IEDispatcher::~IEDispatcher(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::QueryInterface(const IID &riid, void **ppvObject)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ULONG STDMETHODCALLTYPE IEDispatcher::AddRef()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ULONG STDMETHODCALLTYPE IEDispatcher::Release()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfoCount(UINT *pctinfo)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfo(UINT, LCID, ITypeInfo **)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::GetIDsOfNames(const IID &, LPOLESTR *, UINT, LCID, DISPID *)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *)
|
||||||
|
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -6,6 +6,12 @@ class IEDispatcher : public IDispatch
|
|||||||
public:
|
public:
|
||||||
IEDispatcher(void);
|
IEDispatcher(void);
|
||||||
~IEDispatcher(void);
|
~IEDispatcher(void);
|
||||||
HRESULT IEDispatcher::QueryInterface();
|
HRESULT STDMETHODCALLTYPE IEDispatcher::QueryInterface(const IID &riid, void **ppvObject);
|
||||||
HRESULT IEDispatcher::QueryInterface(const IID &riid, void **ppvObject);
|
ULONG STDMETHODCALLTYPE IEDispatcher::AddRef();
|
||||||
|
ULONG STDMETHODCALLTYPE IEDispatcher::Release();
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfoCount(UINT *pctinfo);
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfo(UINT, LCID, ITypeInfo **);
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::GetIDsOfNames(const IID &, LPOLESTR *, UINT, LCID, DISPID *);
|
||||||
|
HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
64
main.cpp
64
main.cpp
@@ -35,11 +35,9 @@
|
|||||||
#include <exdisp.h>
|
#include <exdisp.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <comdef.h>
|
|
||||||
#include <comdefsp.h>
|
|
||||||
#include "ax.h"
|
#include "ax.h"
|
||||||
#include "IEDispatcher.h"
|
#include <cguid.h>
|
||||||
|
#include "IEBrowser.h"
|
||||||
|
|
||||||
#if G3D_VER < 61000
|
#if G3D_VER < 61000
|
||||||
#error Requires G3D 6.10
|
#error Requires G3D 6.10
|
||||||
@@ -48,8 +46,6 @@ HWND hwnd;
|
|||||||
|
|
||||||
DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F);
|
DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F);
|
||||||
HRESULT hresult;
|
HRESULT hresult;
|
||||||
IUnknown * punk;
|
|
||||||
IDispatch * pdisp = new IEDispatcher();
|
|
||||||
OLECHAR dat = ((OLECHAR)"SayHello");
|
OLECHAR dat = ((OLECHAR)"SayHello");
|
||||||
OLECHAR * szMember = &dat;
|
OLECHAR * szMember = &dat;
|
||||||
DISPID dispid;
|
DISPID dispid;
|
||||||
@@ -57,8 +53,6 @@ DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
|
|||||||
EXCEPINFO excepinfo;
|
EXCEPINFO excepinfo;
|
||||||
UINT nArgErr;
|
UINT nArgErr;
|
||||||
|
|
||||||
|
|
||||||
IWebBrowser2* test;
|
|
||||||
static std::string title = "";
|
static std::string title = "";
|
||||||
static DataModelInstance* dataModel;
|
static DataModelInstance* dataModel;
|
||||||
GFontRef fntdominant = NULL;
|
GFontRef fntdominant = NULL;
|
||||||
@@ -91,7 +85,7 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
|
|||||||
_hWndMain = parentWindow;
|
_hWndMain = parentWindow;
|
||||||
|
|
||||||
HMODULE hThisInstance = GetModuleHandle(NULL);
|
HMODULE hThisInstance = GetModuleHandle(NULL);
|
||||||
IWebBrowser2* wb = 0;
|
|
||||||
_hwndToolbox = CreateWindowEx(
|
_hwndToolbox = CreateWindowEx(
|
||||||
WS_EX_ACCEPTFILES,
|
WS_EX_ACCEPTFILES,
|
||||||
"AX",
|
"AX",
|
||||||
@@ -106,31 +100,7 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
|
|||||||
hThisInstance,
|
hThisInstance,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
SendMessage(_hwndToolbox,AX_INPLACE,1,0);
|
|
||||||
SendMessage(_hwndToolbox,AX_QUERYINTERFACE,(WPARAM)&IID_IWebBrowser2,(LPARAM)&wb);
|
|
||||||
if (wb)
|
|
||||||
{
|
|
||||||
wb->Navigate(L"https://scottbeebiwan.tk/g3d/toolbox/",0,0,0,0);
|
|
||||||
wb->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
_buttonTest = CreateWindow(
|
|
||||||
"COMBOBOX",
|
|
||||||
"",
|
|
||||||
CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE ,
|
|
||||||
20,
|
|
||||||
10,
|
|
||||||
80,
|
|
||||||
120,
|
|
||||||
_hwndToolbox, // parent
|
|
||||||
NULL, // menu
|
|
||||||
hThisInstance,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
SendMessage(_buttonTest,(UINT) CB_ADDSTRING,(WPARAM) 0,(LPARAM) "TEST");
|
|
||||||
SendMessage(_buttonTest,(UINT) CB_ADDSTRING,(WPARAM) 0,(LPARAM) "TEST2");
|
|
||||||
SendMessage(_buttonTest, CB_SETCURSEL, (WPARAM)1, (LPARAM)0);
|
|
||||||
_hwndRenderer = CreateWindowEx(
|
_hwndRenderer = CreateWindowEx(
|
||||||
WS_EX_ACCEPTFILES,
|
WS_EX_ACCEPTFILES,
|
||||||
"G3DWindow",
|
"G3DWindow",
|
||||||
@@ -146,10 +116,10 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
Win32Window* window = Win32Window::create(settings.window,_hwndRenderer);
|
Win32Window* window = Win32Window::create(settings.window,_hwndRenderer);
|
||||||
ShowWindow(_hwndRenderer, SW_SHOW);
|
ShowWindow(_hwndRenderer, SW_SHOW);
|
||||||
ShowWindow(_hWndMain, SW_SHOW);
|
ShowWindow(_hWndMain, SW_SHOW);
|
||||||
|
|
||||||
quit=false;
|
quit=false;
|
||||||
rightButtonHolding=false;
|
rightButtonHolding=false;
|
||||||
mouseOnScreen=false;
|
mouseOnScreen=false;
|
||||||
@@ -163,12 +133,15 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
|
|||||||
MessageBox(NULL,"Window not found!","Error",MB_OK);
|
MessageBox(NULL,"Window not found!","Error",MB_OK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_window = renderDevice->window();
|
_window = renderDevice->window();
|
||||||
_window->makeCurrent();
|
_window->makeCurrent();
|
||||||
|
|
||||||
SetWindowLongPtr(_hWndMain,GWL_USERDATA,(LONG)this);
|
SetWindowLongPtr(_hWndMain,GWL_USERDATA,(LONG)this);
|
||||||
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
|
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
|
||||||
SetWindowLongPtr(_hwndToolbox,GWL_USERDATA,(LONG)this);
|
|
||||||
|
IEBrowser* webBrowser = new IEBrowser(_hwndToolbox);
|
||||||
|
webBrowser->navigateSyncURL(L"https://scottbeebiwan.tk/g3d/toolbox/");
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearInstances()
|
void clearInstances()
|
||||||
@@ -1398,13 +1371,13 @@ 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);
|
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);
|
||||||
}
|
//}
|
||||||
switch(msg)
|
switch(msg)
|
||||||
{
|
{
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
break;
|
break;
|
||||||
@@ -1593,8 +1566,11 @@ void Demo::onCreate(HWND parentWindow)
|
|||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
try{
|
try{
|
||||||
hresult = OleInitialize(NULL);
|
hresult = OleInitialize(NULL);
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
hresult = CoCreateInstance(CLSID_G3d, NULL, CLSCTX_SERVER, IID_IUnknown, (void **)&punk);
|
hresult = CoCreateInstance(CLSID_G3d, NULL, CLSCTX_SERVER, IID_IUnknown, (void **)&punk);
|
||||||
hresult = punk->QueryInterface(IID_IDispatch, &pdisp);
|
hresult = punk->QueryInterface(IID_IDispatch, (void **)&pdisp);
|
||||||
|
>>>>>>> db4c46cf20d280b99ab13d892c809de8108d4862
|
||||||
if (!AXRegister())
|
if (!AXRegister())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -1634,7 +1610,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
if(hwndMain == NULL)
|
if(hwndMain == NULL)
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Failed to create HWND",placeholderName+" Crash", MB_OK);
|
MessageBox(NULL, "Failed to create HWND", (PlaceholderName + " Crash").c_str() , MB_OK);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SendMessage(hwndMain, WM_SETICON, ICON_BIG,(LPARAM)LoadImage(GetModuleHandle(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE));
|
SendMessage(hwndMain, WM_SETICON, ICON_BIG,(LPARAM)LoadImage(GetModuleHandle(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE));
|
||||||
|
|||||||
Reference in New Issue
Block a user