diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 8a85feae..8ddcf2bb 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1472,6 +1472,22 @@ CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& config) return NULL; } + +CMeterWindow* CRainmeter::GetMeterWindow(HWND hwnd) +{ + std::map::iterator iter = m_Meters.begin(); + + for (; iter != m_Meters.end(); iter++) + { + if ((*iter).second->GetWindow() == hwnd) + { + return (*iter).second; + } + } + + return NULL; +} + /* ** Quit ** diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index c1ec1129..6ed849b8 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -112,6 +112,7 @@ public: CTrayWindow* GetTrayWindow() { return m_TrayWindow; }; CMeterWindow* GetMeterWindow(const std::wstring& config); + CMeterWindow* GetMeterWindow(HWND hwnd); std::map& GetAllMeterWindows() { return m_Meters; }; const std::vector& GetAllConfigs() { return m_ConfigStrings; }; const std::vector& GetAllThemes() { return m_Themes; }; diff --git a/Library/System.cpp b/Library/System.cpp index 9bfe5377..2f0aeb8f 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -581,7 +581,8 @@ BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam) if (GetClassName(hwnd, className, 128) > 0 && wcscmp(className, L"RainmeterMeterWindow") == 0 && - (Window = (CMeterWindow*)GetProp(hwnd, L"RAINMETER"))) + Rainmeter && + (Window = Rainmeter->GetMeterWindow(hwnd))) { if (Window->GetWindowZPosition() == ZPOSITION_ONDESKTOP) {