Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions mods/disable-inactive-menubar-greying.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id disable-inactive-menubar-greying
// @name Disable Inactive Menubar Greying
// @description Prevents menubar text from being greyed out in inactive folder windows in Classic theme
// @version 1.3
// @version 1.4
// @author Anixx
// @github https://github.com/Anixx
// @include explorer.exe
Expand All @@ -17,6 +17,8 @@ This mod prevents the classic menubar text (File, Edit, View, etc.) in folder wi
under the Classic theme from appearing greyed out when the window loses focus,
the way it was in Windows 95, before Windows 98.

The current version of the mod intended for Windows 10 version 1607 or higher.

![screenshot](https://i.imgur.com/FCEXTyt.png)

![screenshot](https://i.imgur.com/XBVNN0v.png)
Expand All @@ -27,8 +29,11 @@ the way it was in Windows 95, before Windows 98.
typedef COLORREF (WINAPI *SetTextColor_t)(HDC hdc, COLORREF color);
SetTextColor_t SetTextColor_Original;

thread_local bool checked=false;
thread_local bool found=false;
typedef HRESULT (WINAPI *GetThreadDescription_t)(HANDLE hThread, PWSTR* ppszThreadDescription);
GetThreadDescription_t pGetThreadDescription;

thread_local bool checked = false;
thread_local bool found = false;

bool IsGreyColor(COLORREF color, COLORREF menuTextColor)
{
Expand Down Expand Up @@ -57,28 +62,26 @@ bool IsCurrentThreadWindowFocused()
return fgThreadId == GetCurrentThreadId();
}

BOOL CALLBACK EnumThreadWndProc_CheckTaskbar(HWND hwnd, LPARAM lParam)
// Возвращает true, если текущий поток - это поток панели задач (имя потока "Taskbar")
bool IsCurrentThreadTaskbar()
{
wchar_t className[256];
if (GetClassNameW(hwnd, className, 256) > 0)
if (checked)
return found;

checked = true;
found = false;

if (pGetThreadDescription)
{
if (wcscmp(className, L"Shell_TrayWnd") == 0 ||
wcscmp(className, L"Shell_SecondaryTrayWnd") == 0)
PWSTR desc = nullptr;
HRESULT hr = pGetThreadDescription(GetCurrentThread(), &desc);
if (SUCCEEDED(hr) && desc)
{
*(bool*)lParam = true;
return FALSE; // нашли, прекращаем перебор
found = (wcscmp(desc, L"Taskbar") == 0);
LocalFree(desc);
}
}
return TRUE; // продолжаем перебор
}

// Возвращает true, если текущий поток владеет хотя бы одним окном панели задач
bool IsCurrentThreadTaskbar()
{
if (!checked) {
EnumThreadWindows(GetCurrentThreadId(), EnumThreadWndProc_CheckTaskbar, (LPARAM)&found);
checked=true;
}
return found;
}

Expand All @@ -97,6 +100,9 @@ COLORREF WINAPI SetTextColor_Hook(HDC hdc, COLORREF color)

BOOL Wh_ModInit()
{
pGetThreadDescription = (GetThreadDescription_t)GetProcAddress(
GetModuleHandle(L"kernel32.dll"), "GetThreadDescription");

Wh_SetFunctionHook(
(void*)GetProcAddress(GetModuleHandle(L"gdi32.dll"), "SetTextColor"),
(void*)SetTextColor_Hook,
Expand Down
Loading