diff --git a/.gitignore b/.gitignore index a20e3db..cde6729 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,4 @@ G3DTest.suo G3DTest.suo stderr.txt desktop.ini -main.cpp *.db -G3DTest.sln diff --git a/G3DTest.vcproj b/G3DTest.vcproj index 6ef896f..400b4b8 100644 --- a/G3DTest.vcproj +++ b/G3DTest.vcproj @@ -50,6 +50,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" + AdditionalIncludeDirectories=""C:\Users\Andreja\Documents\C++\G3D-Fun\src\include"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" StringPooling="true" RuntimeLibrary="2" diff --git a/content/page/color.html b/content/page/color.html index acdb23f..3e32a75 100644 --- a/content/page/color.html +++ b/content/page/color.html @@ -78,7 +78,7 @@ } } - +
diff --git a/content/page/controller.html b/content/page/controller.html index 3feb4d6..5b9bef4 100644 --- a/content/page/controller.html +++ b/content/page/controller.html @@ -11,7 +11,7 @@ image.src = image.src.replace("_dn.png",".png"); } - + diff --git a/content/page/hopper.html b/content/page/hopper.html index f20c4a0..b3478a8 100644 --- a/content/page/hopper.html +++ b/content/page/hopper.html @@ -21,7 +21,7 @@ margin-right: 10px; } - + diff --git a/content/page/surface.html b/content/page/surface.html index a165e6a..1b1b295 100644 --- a/content/page/surface.html +++ b/content/page/surface.html @@ -11,7 +11,7 @@ image.src = image.src.replace("_dn.png",".png"); } - + diff --git a/src/include/IEBrowser.h b/src/include/IEBrowser.h index 15b3264..adb3b73 100644 --- a/src/include/IEBrowser.h +++ b/src/include/IEBrowser.h @@ -24,5 +24,5 @@ class IEBrowser { unsigned int FAR* puArgErr); private: IWebBrowser2* webBrowser; - HWND hwnd; + HWND parentHwnd; }; diff --git a/src/include/WindowFunctions.h b/src/include/WindowFunctions.h index 9b3aeb7..c20de62 100644 --- a/src/include/WindowFunctions.h +++ b/src/include/WindowFunctions.h @@ -1,4 +1,5 @@ #pragma once #include + bool createWindowClass(const char* name,WNDPROC proc,HMODULE hInstance); \ No newline at end of file diff --git a/src/source/IEBrowser.cpp b/src/source/IEBrowser.cpp index cb42c00..b67b75e 100644 --- a/src/source/IEBrowser.cpp +++ b/src/source/IEBrowser.cpp @@ -65,7 +65,7 @@ HRESULT IEBrowser::doExternal(std::wstring funcName, DWORD rgbCurrent = 0xFFFFFFFF; //Will be dynamic later ZeroMemory(&color, sizeof(CHOOSECOLOR)); color.lStructSize = sizeof(color); - color.hwndOwner = hwnd; + color.hwndOwner = parentHwnd; color.lpCustColors = (LPDWORD) g_acrCustClr; color.rgbResult = rgbCurrent; color.Flags = CC_FULLOPEN | CC_RGBINIT; @@ -91,19 +91,19 @@ HRESULT IEBrowser::doExternal(std::wstring funcName, } IEBrowser::IEBrowser(HWND attachHWnd) { + webBrowser = 0; + parentHwnd = attachHWnd; MSG messages; while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE)) { - if (IsDialogMessage(hwnd, &messages) == 0) + if (IsDialogMessage(parentHwnd, &messages) == 0) { TranslateMessage(&messages); DispatchMessage(&messages); } } - hwnd = attachHWnd; - webBrowser = 0; - SendMessage(hwnd,AX_INPLACE,1,0); - SendMessage(hwnd,AX_QUERYINTERFACE,(WPARAM)&IID_IWebBrowser2,(LPARAM)&webBrowser); + SendMessage(parentHwnd,AX_INPLACE,1,0); + SendMessage(parentHwnd,AX_QUERYINTERFACE,(WPARAM)&IID_IWebBrowser2,(LPARAM)&webBrowser); } IEBrowser::~IEBrowser(void) { diff --git a/src/source/Mouse.cpp b/src/source/Mouse.cpp index 3ead8d0..5cae677 100644 --- a/src/source/Mouse.cpp +++ b/src/source/Mouse.cpp @@ -1,7 +1,6 @@ #include "Mouse.h" #include "Application.h" #include "Globals.h" -#include Mouse::Mouse(){ x = y = 0; diff --git a/src/source/StringFunctions.cpp b/src/source/StringFunctions.cpp index 5e9025b..067da01 100644 --- a/src/source/StringFunctions.cpp +++ b/src/source/StringFunctions.cpp @@ -2,7 +2,6 @@ #include #include "ErrorFunctions.h" #include "StringFunctions.h" -#include std::string Convert (float number) { diff --git a/src/source/WindowFunctions.cpp b/src/source/WindowFunctions.cpp index 4593dcd..218508f 100644 --- a/src/source/WindowFunctions.cpp +++ b/src/source/WindowFunctions.cpp @@ -1,7 +1,6 @@ #include "WindowFunctions.h" #include -#include using namespace std; diff --git a/src/source/main.cpp b/src/source/main.cpp new file mode 100644 index 0000000..35cb162 --- /dev/null +++ b/src/source/main.cpp @@ -0,0 +1,221 @@ +// TODO: Move toolbar buttons with resized window. +#define _WIN32_WINNT 0x0400 +#define _WIN32_WINDOWS 0x0400 +#define WINVER 0x0400 + +#include "resource.h" +#include "Application.h" +#include "WindowFunctions.h" +#include "ax.h" +#include +#include "ErrorFunctions.h" + +#if G3D_VER < 61000 + #error Requires G3D 6.10 +#endif +HWND hwnd; + +HRESULT hresult; +OLECHAR dat = ((OLECHAR)"SayHello"); +OLECHAR * szMember = &dat; +DISPID dispid; +DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; +EXCEPINFO excepinfo; +UINT nArgErr; + +LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + Application *app = (Application *)GetWindowLongPtr(hwnd, GWL_USERDATA); + if (app==NULL) + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + switch(msg) + { + case WM_KEYDOWN: + if ((HIWORD(lParam)&0x4000)==0) // single key press + { + app->onKeyPressed(wParam); + } + break; + case WM_KEYUP: + { + app->onKeyUp(wParam); + } + break; + case WM_MOUSEWHEEL: + app->onMouseWheel(LOWORD(lParam),HIWORD(lParam),HIWORD(wParam)); + break; + case WM_SIZE: + app->resizeWithParent(hwnd); + break; + case WM_ACTIVATE: + if(wParam > WA_INACTIVE) app->setFocus(false); + else app->setFocus(true); + default: + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + } + return 0; +} + +LRESULT CALLBACK ToolboxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + //Application *app = (Application *)GetWindowLongPtr(hwnd, GWL_USERDATA); + MessageBox(NULL, (LPCSTR)wParam, (LPCSTR)lParam, 1); + //if (app==NULL) + //{ + //return DefWindowProc(hwnd, msg, wParam, lParam); + //} + switch(msg) + { + case WM_SIZE: + break; + default: + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + } + return 0; +} + +LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + Application *app = (Application *)GetWindowLongPtr(hwnd, GWL_USERDATA); + if (app==NULL) + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + switch(msg) + { + case WM_QUIT: + app->QuitApp(); + break; + case WM_DESTROY: + app->QuitApp(); + break; + case WM_LBUTTONDOWN: + app->onMouseLeftPressed(hwnd,LOWORD(lParam),HIWORD(lParam)); + break; + case WM_LBUTTONUP: + app->onMouseLeftUp(app->getRenderDevice(),LOWORD(lParam),HIWORD(lParam)); + break; + case WM_RBUTTONDOWN: + app->onMouseRightPressed(LOWORD(lParam),HIWORD(lParam)); + break; + case WM_RBUTTONUP: + app->onMouseRightUp(LOWORD(lParam),HIWORD(lParam)); + break; + case WM_MOUSEMOVE: + app->onMouseMoved(LOWORD(lParam),HIWORD(lParam)); + break; + case WM_KEYDOWN: + if ((HIWORD(lParam)&0x4000)==0) // single key press + { + app->onKeyPressed(wParam); + } + break; + case WM_KEYUP: + { + app->onKeyUp(wParam); + } + break; + case WM_SYSKEYDOWN: + if ((HIWORD(lParam)&0x4000)==0) // single key press + { + app->onKeyPressed(wParam); + } + break; + case WM_SYSKEYUP: + { + app->onKeyUp(wParam); + } + case WM_SIZE: + { + app->onGraphics(app->getRenderDevice()); + } + break; + default: + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + } + + return 0; +} + +int main(int argc, char** argv) { + try{ + hresult = OleInitialize(NULL); + +/* IInternetSecurityManager *pSecurityMgr; + IInternetZoneManager *pZoneMgr; + LPCWSTR site1 = SysAllocString(L"http://www.androdome.com"); + + hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_INPROC_SERVER, IID_IInternetSecurityManager, (void**)&pSecurityMgr); + + pSecurityMgr->SetZoneMapping((DWORD)2, site1, (DWORD)0); // 2 = Trusted Site, site1 is the URL to add, and 0 is to create the entry. +*/ + + + + if (!AXRegister()) + return 0; + + + INITCOMMONCONTROLSEX icc; +// WNDCLASSEX wcx; + + /* Initialize common controls. Also needed for MANIFEST's */ + + icc.dwSize = sizeof(icc); + icc.dwICC = ICC_WIN95_CLASSES/*|ICC_COOL_CLASSES|ICC_DATE_CLASSES| + ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES*/; + InitCommonControlsEx(&icc); + + AudioPlayer::init(); + /* GAppSettings settings; + settings.window.resizable = true; + settings.writeLicenseFile = false; + settings.window.center = true; */ + HMODULE hThisInstance = GetModuleHandle(NULL); + + if (!createWindowClass("mainHWND",WndProc,hThisInstance)) + return false; + if (!createWindowClass("toolboxHWND",ToolboxProc,hThisInstance)) + return false; + if (!createWindowClass("G3DWindow",G3DProc,hThisInstance)) + return false; + + HWND hwndMain = CreateWindowEx( + WS_EX_APPWINDOW, + "mainHWND", + "Main test", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + 800, + 660, + NULL, // parent + NULL, // menu + hThisInstance, + NULL + ); + if(hwndMain == NULL) + { + MessageBox(NULL, "Critical error loading: Failed to create HWND, must exit", (g_PlaceholderName + " Crash").c_str() , MB_OK); + return 0; + } + SendMessage(hwndMain, WM_SETICON, ICON_BIG,(LPARAM)LoadImage(GetModuleHandle(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE)); + + + Application app = Application(hwndMain); + app.run(); + } + catch(...) + { + OnError(-1); + } + return 0; +}