From af8be416636c635ed2cf6d08e409b07f5628707d Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 18 Nov 2011 07:33:41 +0000 Subject: [PATCH] Minor tweaks. --- Library/System.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Library/System.cpp b/Library/System.cpp index cf929aae..5847dc0c 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -597,8 +597,9 @@ HWND CSystem::GetDefaultShellWindow() } else { - WCHAR className[16]; - if (!(GetClassName(ShellW, className, 16) > 0 && + const int classLen = _countof(L"Progman"); + WCHAR className[classLen]; + if (!(GetClassName(ShellW, className, classLen) > 0 && wcscmp(className, L"Progman") == 0)) { ShellW = NULL; @@ -634,8 +635,9 @@ HWND CSystem::GetWorkerW() } else { - WCHAR className[16]; - if (GetClassName(parent, className, 16) > 0 && + const int classLen = _countof(L"WorkerW"); + WCHAR className[classLen]; + if (GetClassName(parent, className, classLen) > 0 && wcscmp(className, L"WorkerW") == 0) { return parent; @@ -714,11 +716,12 @@ bool CSystem::BelongToSameProcess(HWND hwndA, HWND hwndB) BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam) { bool logging = Rainmeter->GetDebug() && DEBUG_VERBOSE; - WCHAR className[64]; + const int classLen = _countof(METERWINDOW_CLASS_NAME) + (DEBUG_VERBOSE ? 32 : 0); + WCHAR className[classLen]; CMeterWindow* Window; WCHAR flag; - if (GetClassName(hwnd, className, 64) > 0 && + if (GetClassName(hwnd, className, classLen) > 0 && wcscmp(className, METERWINDOW_CLASS_NAME) == 0 && (Window = Rainmeter->GetMeterWindow(hwnd))) { @@ -773,7 +776,7 @@ void CSystem::ChangeZPosInOrder() // Retrieve the Rainmeter's meter windows in Z-order EnumWindows(MyEnumWindowsProc, (LPARAM)(&windowsInZOrder)); - auto resetZPos = [=](ZPOSITION zpos) + auto resetZPos = [&](ZPOSITION zpos) { // Reset ZPos in Z-order (Bottom) std::vector::const_iterator iter = windowsInZOrder.begin(), iterEnd = windowsInZOrder.end(); @@ -935,8 +938,9 @@ void CALLBACK CSystem::MyWinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, { if (!c_ShowDesktop) { - WCHAR className[16]; - if (GetClassName(hwnd, className, 16) > 0 && + const int classLen = _countof(L"WorkerW"); + WCHAR className[classLen]; + if (GetClassName(hwnd, className, classLen) > 0 && wcscmp(className, L"WorkerW") == 0 && BelongToSameProcess(GetDefaultShellWindow(), hwnd)) {