Fixed an issue that !RainmeterZPos (1/2) fails in some cases.

This commit is contained in:
spx 2010-11-24 22:30:18 +00:00
parent 8722009407
commit d299d89ede
2 changed files with 32 additions and 10 deletions

View File

@ -539,15 +539,18 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
{ {
if(!m_ChildWindow) if(!m_ChildWindow)
{ {
HWND winPos = HWND_NOTOPMOST;
m_WindowZPosition = zPos; m_WindowZPosition = zPos;
HWND winPos = HWND_NOTOPMOST;
UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING;
switch (zPos) switch (zPos)
{ {
case ZPOSITION_ONTOPMOST: case ZPOSITION_ONTOPMOST:
case ZPOSITION_ONTOP: case ZPOSITION_ONTOP:
winPos = HWND_TOPMOST; winPos = HWND_TOPMOST;
break; flags |= SWP_NOOWNERZORDER;
break;
case ZPOSITION_ONBOTTOM: case ZPOSITION_ONBOTTOM:
if (all) if (all)
@ -572,13 +575,15 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
case ZPOSITION_ONDESKTOP: case ZPOSITION_ONDESKTOP:
if (CSystem::GetShowDesktop()) if (CSystem::GetShowDesktop())
{ {
flags |= SWP_NOOWNERZORDER;
// Set WS_EX_TOPMOST flag // Set WS_EX_TOPMOST flag
SetWindowPos(m_Window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING); SetWindowPos(m_Window, HWND_TOPMOST, 0, 0, 0, 0, flags);
if (all) if (all)
{ {
// Insert after the helper window // Insert after the helper window
SetWindowPos(m_Window, CSystem::GetHelperWindow(), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING); SetWindowPos(m_Window, CSystem::GetHelperWindow(), 0, 0, 0, 0, flags);
} }
else else
{ {
@ -589,7 +594,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
if (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) if (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
{ {
// Insert after the found window // Insert after the found window
if (0 != SetWindowPos(m_Window, hwnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING)) if (0 != SetWindowPos(m_Window, hwnd, 0, 0, 0, 0, flags))
{ {
break; break;
} }
@ -613,7 +618,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
break; break;
} }
SetWindowPos(m_Window, winPos, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); SetWindowPos(m_Window, winPos, 0, 0, 0, 0, flags);
} }
} }

View File

@ -682,7 +682,7 @@ BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam)
Rainmeter && (Window = Rainmeter->GetMeterWindow(hwnd))) Rainmeter && (Window = Rainmeter->GetMeterWindow(hwnd)))
{ {
ZPOSITION zPos = Window->GetWindowZPosition(); ZPOSITION zPos = Window->GetWindowZPosition();
if (zPos == ZPOSITION_ONDESKTOP) if (zPos == ZPOSITION_ONDESKTOP || zPos == ZPOSITION_ONBOTTOM)
{ {
if (logging) DebugLog(L"+ [%c] 0x%08X : %s (Name: \"%s\", zPos=%i)", IsWindowVisible(hwnd) ? L'V' : L'H', hwnd, className, Window->GetSkinName().c_str(), (int)zPos); if (logging) DebugLog(L"+ [%c] 0x%08X : %s (Name: \"%s\", zPos=%i)", IsWindowVisible(hwnd) ? L'V' : L'H', hwnd, className, Window->GetSkinName().c_str(), (int)zPos);
@ -722,10 +722,27 @@ void CSystem::ChangeZPosInOrder()
// Retrieve the Rainmeter's meter windows in Z-order // Retrieve the Rainmeter's meter windows in Z-order
EnumWindows(MyEnumWindowsProc, (LPARAM)(&windowsInZOrder)); EnumWindows(MyEnumWindowsProc, (LPARAM)(&windowsInZOrder));
// Reset ZPos in Z-order if (!c_ShowDesktop)
for (size_t i = 0; i < windowsInZOrder.size(); ++i)
{ {
windowsInZOrder[i]->ChangeZPos(windowsInZOrder[i]->GetWindowZPosition()); // reset // Reset ZPos in Z-order (Bottom)
std::vector<CMeterWindow*>::const_iterator iter = windowsInZOrder.begin(), iterEnd = windowsInZOrder.end();
for ( ; iter != iterEnd; ++iter)
{
if ((*iter)->GetWindowZPosition() == ZPOSITION_ONBOTTOM)
{
(*iter)->ChangeZPos(ZPOSITION_ONBOTTOM); // reset
}
}
}
// Reset ZPos in Z-order (On Desktop)
std::vector<CMeterWindow*>::const_iterator iter = windowsInZOrder.begin(), iterEnd = windowsInZOrder.end();
for ( ; iter != iterEnd; ++iter)
{
if ((*iter)->GetWindowZPosition() == ZPOSITION_ONDESKTOP)
{
(*iter)->ChangeZPos(ZPOSITION_ONDESKTOP); // reset
}
} }
if (logging) if (logging)