/* ** Returns the first window whose position is not ZPOSITION_ONDESKTOP, ** ZPOSITION_BOTTOM, or ZPOSITION_NORMAL. ** */ HWND System::GetBackmostTopWindow() { HWND winPos = c_HelperWindow; // Skip all ZPOSITION_ONDESKTOP, ZPOSITION_BOTTOM, and ZPOSITION_NORMAL windows while (winPos = ::GetNextWindow(winPos, GW_HWNDPREV)) { MeterWindow* wnd = GetRainmeter().GetMeterWindow(winPos); if (!wnd || (wnd->GetWindowZPosition() != ZPOSITION_NORMAL && wnd->GetWindowZPosition() != ZPOSITION_ONDESKTOP && wnd->GetWindowZPosition() != ZPOSITION_ONBOTTOM)) { break; } } return winPos; }
/* ** Retrieves the Rainmeter's meter windows in Z-order. ** */ BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam) { bool logging = GetRainmeter().GetDebug() && DEBUG_VERBOSE; const int classLen = _countof(METERWINDOW_CLASS_NAME) + (DEBUG_VERBOSE ? 32 : 1); WCHAR className[classLen]; MeterWindow* Window; WCHAR flag; if (GetClassName(hwnd, className, classLen) > 0 && wcscmp(className, METERWINDOW_CLASS_NAME) == 0 && (Window = GetRainmeter().GetMeterWindow(hwnd))) { ZPOSITION zPos = Window->GetWindowZPosition(); if (zPos == ZPOSITION_ONDESKTOP || (zPos == ZPOSITION_NORMAL && GetRainmeter().IsNormalStayDesktop()) || zPos == ZPOSITION_ONBOTTOM) { if (lParam) { ((std::vector<MeterWindow*>*)lParam)->push_back(Window); } if (logging) flag = L'+'; } else { if (logging) flag = L'-'; } if (logging) { LogDebugF(L"%c [%c] 0x%p : %s (Name: \"%s\", zPos=%i)", flag, IsWindowVisible(hwnd) ? L'V' : L'H', hwnd, className, Window->GetFolderPath().c_str(), (int)zPos); } } else { if (logging) { flag = (hwnd == System::GetHelperWindow()) ? L'o' : ' '; LogDebugF(L"%c [%c] 0x%p : %s", flag, IsWindowVisible(hwnd) ? L'V' : L'H', hwnd, className); } } return TRUE; }