From 78cb8b2543808ebbcdc0185334cd91ca5438a71c Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 26 Nov 2010 16:17:23 +0000 Subject: [PATCH] Fixed an issue that AlwaysOnTop=-1/-2 fails on startup. --- Library/MeterWindow.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 878b2aec..cf52d099 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -536,19 +536,18 @@ void CMeterWindow::MoveWindow(int x, int y) */ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all) { +#define ZPOS_FLAGS (SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING) + if(!m_ChildWindow) { - m_WindowZPosition = zPos; - HWND winPos = HWND_NOTOPMOST; - UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING; + m_WindowZPosition = zPos; switch (zPos) { case ZPOSITION_ONTOPMOST: case ZPOSITION_ONTOP: winPos = HWND_TOPMOST; - flags |= SWP_NOOWNERZORDER; break; case ZPOSITION_ONBOTTOM: @@ -574,15 +573,13 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all) case ZPOSITION_ONDESKTOP: if (CSystem::GetShowDesktop()) { - flags |= SWP_NOOWNERZORDER; - // Set WS_EX_TOPMOST flag - SetWindowPos(m_Window, HWND_TOPMOST, 0, 0, 0, 0, flags); + SetWindowPos(m_Window, HWND_TOPMOST, 0, 0, 0, 0, ZPOS_FLAGS); if (all) { // Insert after the helper window - SetWindowPos(m_Window, CSystem::GetHelperWindow(), 0, 0, 0, 0, flags); + SetWindowPos(m_Window, CSystem::GetHelperWindow(), 0, 0, 0, 0, ZPOS_FLAGS); } else { @@ -593,7 +590,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all) if (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) { // Insert after the found window - if (0 != SetWindowPos(m_Window, hwnd, 0, 0, 0, 0, flags)) + if (0 != SetWindowPos(m_Window, hwnd, 0, 0, 0, 0, ZPOS_FLAGS)) { break; } @@ -617,7 +614,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all) break; } - SetWindowPos(m_Window, winPos, 0, 0, 0, 0, flags); + SetWindowPos(m_Window, winPos, 0, 0, 0, 0, ZPOS_FLAGS); } }