Additional change for r897.

This commit is contained in:
spx 2011-08-13 10:03:16 +00:00
parent 04ebdd5186
commit fab4bdb088
3 changed files with 40 additions and 17 deletions

View File

@ -3540,7 +3540,7 @@ void CRainmeter::RefreshAll()
GetMeterWindowsByLoadOrder(windows);
// Prepare the helper window
CSystem::PrepareHelperWindow(CSystem::GetWorkerW());
CSystem::PrepareHelperWindow();
// Refresh all
std::multimap<int, CMeterWindow*>::const_iterator iter = windows.begin();

View File

@ -561,44 +561,68 @@ HWND CSystem::GetDefaultShellWindow()
else
{
WCHAR className[16];
if (GetClassName(ShellW, className, 16) > 0 &&
wcscmp(className, L"Progman") == 0)
if (!(GetClassName(ShellW, className, 16) > 0 &&
wcscmp(className, L"Progman") == 0))
{
c_ShellW = ShellW;
return ShellW;
ShellW = NULL;
}
}
}
c_ShellW = NULL;
return NULL;
c_ShellW = ShellW;
return ShellW;
}
/*
** GetWorkerW
**
** Finds the WorkerW window.
** If the window is not found, returns NULL.
** If the WorkerW window is not active, returns NULL.
**
*/
HWND CSystem::GetWorkerW()
{
static HWND c_DefView = NULL; // cache
HWND ShellW = GetDefaultShellWindow();
if (!ShellW) return NULL; // Default Shell (Explorer) not running
if (FindWindowEx(ShellW, NULL, L"SHELLDLL_DefView", L"") == NULL)
if (c_DefView && IsWindow(c_DefView))
{
HWND WorkerW = NULL;
while (WorkerW = FindWindowEx(NULL, WorkerW, L"WorkerW", L""))
HWND parent = GetAncestor(c_DefView, GA_PARENT);
if (parent)
{
if (BelongToSameProcess(ShellW, WorkerW) && FindWindowEx(WorkerW, NULL, L"SHELLDLL_DefView", L""))
if (parent == ShellW)
{
return WorkerW;
return NULL;
}
else
{
WCHAR className[16];
if (GetClassName(parent, className, 16) > 0 &&
wcscmp(className, L"WorkerW") == 0)
{
return parent;
}
}
}
}
return NULL;
HWND WorkerW = NULL, DefView = FindWindowEx(ShellW, NULL, L"SHELLDLL_DefView", L"");
if (DefView == NULL)
{
while (WorkerW = FindWindowEx(NULL, WorkerW, L"WorkerW", L""))
{
if (IsWindowVisible(WorkerW) &&
BelongToSameProcess(ShellW, WorkerW) &&
(DefView = FindWindowEx(WorkerW, NULL, L"SHELLDLL_DefView", L"")))
{
break;
}
}
}
c_DefView = DefView;
return WorkerW;
}
/*

View File

@ -66,10 +66,8 @@ public:
static bool GetShowDesktop() { return c_ShowDesktop; }
static HWND GetWorkerW();
static HWND GetHelperWindow() { return c_HelperWindow; }
static void PrepareHelperWindow(HWND WorkerW);
static void PrepareHelperWindow(HWND WorkerW = GetWorkerW());
static OSPLATFORM GetOSPlatform();
static ULONGLONG GetTickCount64();
@ -93,6 +91,7 @@ private:
static void UpdateWorkareaInfo();
static HWND GetDefaultShellWindow();
static HWND GetWorkerW();
static void ChangeZPosInOrder();
static bool CheckDesktopState(HWND WorkerW);