Quick initialization fix. Small mouse bug fixed too.

This commit is contained in:
MusicalProgrammer
2018-06-12 14:24:14 -04:00
parent 018c4a1557
commit 5c90258546
2 changed files with 8 additions and 6 deletions

2
Demo.h
View File

@@ -22,7 +22,7 @@ class Demo { // : public GApp {
void onCreate(HWND parentWindow); void onCreate(HWND parentWindow);
void onKeyPressed(int key); void onKeyPressed(int key);
void onKeyUp(int key); void onKeyUp(int key);
void onMouseLeftPressed(int x, int y); void onMouseLeftPressed(HWND hwnd,int x, int y);
void onMouseLeftUp(int x, int y); void onMouseLeftUp(int x, int y);
void onMouseRightPressed(int x, int y); void onMouseRightPressed(int x, int y);
void onMouseRightUp(int x, int y); void onMouseRightUp(int x, int y);

View File

@@ -118,9 +118,6 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
Win32Window* window = Win32Window::create(settings.window,_hwndRenderer); Win32Window* window = Win32Window::create(settings.window,_hwndRenderer);
ShowWindow(_hwndRenderer, SW_SHOW); ShowWindow(_hwndRenderer, SW_SHOW);
SetWindowLongPtr(_hWndMain,GWL_USERDATA,(LONG)this);
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
SetWindowLongPtr(_hwndToolbox,GWL_USERDATA,(LONG)this);
ShowWindow(_hWndMain, SW_SHOW); ShowWindow(_hWndMain, SW_SHOW);
quit=false; quit=false;
rightButtonHolding=false; rightButtonHolding=false;
@@ -138,6 +135,9 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
_window = renderDevice->window(); _window = renderDevice->window();
_window->makeCurrent(); _window->makeCurrent();
SetWindowLongPtr(_hWndMain,GWL_USERDATA,(LONG)this);
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
SetWindowLongPtr(_hwndToolbox,GWL_USERDATA,(LONG)this);
} }
void clearInstances() void clearInstances()
@@ -1200,8 +1200,10 @@ void Demo::onKeyUp(int key)
} }
void Demo::onMouseLeftPressed(int x,int y) void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
{ {
SetFocus(hwnd);
std::cout << "Click: " << x << "," << y << std::endl; std::cout << "Click: " << x << "," << y << std::endl;
bool onGUI = false; bool onGUI = false;
@@ -1379,7 +1381,7 @@ LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
app->QuitApp(); app->QuitApp();
break; break;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
app->onMouseLeftPressed(LOWORD(lParam),HIWORD(lParam)); app->onMouseLeftPressed(hwnd,LOWORD(lParam),HIWORD(lParam));
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
app->onMouseLeftUp(LOWORD(lParam),HIWORD(lParam)); app->onMouseLeftUp(LOWORD(lParam),HIWORD(lParam));