From 01bc10f85284b37625b363b2508ada5b92b51f67 Mon Sep 17 00:00:00 2001 From: andreja6 Date: Tue, 5 Nov 2019 22:51:27 -0800 Subject: [PATCH] Attempted to make property window always on top... ineffective --- Application.cpp | 16 +++++++++++++--- Application.h | 1 + main.cpp | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Application.cpp b/Application.cpp index af3d189..338558c 100644 --- a/Application.cpp +++ b/Application.cpp @@ -54,6 +54,16 @@ PartInstance* Application::makePart() return part; } +void Application::setFocus(bool focus) +{ + if(focus) + { + MessageBox(NULL, "NO", "NO", MB_OK); + SetWindowPos(_propWindow->_hwndProp, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + else SetWindowPos(_propWindow->_hwndProp, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); +} + Application::Application(HWND parentWindow) { //: GApp(settings,window) { @@ -730,9 +740,9 @@ void Application::onMouseLeftPressed(HWND hwnd,int x,int y) if(g_selectedInstances.at(i) == test) { found = true; - ShowWindow(_propWindow->_hwndProp, SW_SHOW); - SetActiveWindow(_propWindow->_hwndProp); - SetForegroundWindow(_propWindow->_hwndProp); + //ShowWindow(_propWindow->_hwndProp, SW_SHOW); + //SetActiveWindow(_propWindow->_hwndProp); + //SetForegroundWindow(_propWindow->_hwndProp); break; } } diff --git a/Application.h b/Application.h index 0662264..5835f21 100644 --- a/Application.h +++ b/Application.h @@ -43,6 +43,7 @@ class Application { // : public GApp { void onMouseRightUp(int x, int y); void onMouseMoved(int x, int y); void onMouseWheel(int x, int y, short delta); + void setFocus(bool isFocused); int getMode(); CameraController cameraController; UserInput* userInput; diff --git a/main.cpp b/main.cpp index b401877..962cf28 100644 --- a/main.cpp +++ b/main.cpp @@ -74,6 +74,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SIZE: app->resizeWithParent(hwnd); break; + case WM_ACTIVATEAPP: + if(wParam == FALSE) app->setFocus(false); + else app->setFocus(true); + break; default: { return DefWindowProc(hwnd, msg, wParam, lParam);