Fixed the crash problem when multiple Rainmeter instances are running and "show desktop" occured.

This commit is contained in:
spx 2010-03-23 16:15:07 +00:00
parent 22deccb366
commit 8b9e21e38f
3 changed files with 19 additions and 1 deletions

View File

@ -1472,6 +1472,22 @@ CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& config)
return NULL;
}
CMeterWindow* CRainmeter::GetMeterWindow(HWND hwnd)
{
std::map<std::wstring, CMeterWindow*>::iterator iter = m_Meters.begin();
for (; iter != m_Meters.end(); iter++)
{
if ((*iter).second->GetWindow() == hwnd)
{
return (*iter).second;
}
}
return NULL;
}
/*
** Quit
**

View File

@ -112,6 +112,7 @@ public:
CTrayWindow* GetTrayWindow() { return m_TrayWindow; };
CMeterWindow* GetMeterWindow(const std::wstring& config);
CMeterWindow* GetMeterWindow(HWND hwnd);
std::map<std::wstring, CMeterWindow*>& GetAllMeterWindows() { return m_Meters; };
const std::vector<CONFIG>& GetAllConfigs() { return m_ConfigStrings; };
const std::vector<std::wstring>& GetAllThemes() { return m_Themes; };

View File

@ -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)
{