1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2025-01-11 05:22:13 +01:00

Taskbar10: Better TaskbarSd handling. (#4020)

- Invisible mode (2) now supports ep_taskbar. We do this by completely overriding WM_PAINT and WM_PRINTCLIENT when this mode is active, instead of null-ing the HTHEME.
- Disabled mode (1) now hides the window instead of returning 0 (width/height value depending on taskbar orientation) in message 0x464 (calculate minimum size). Fortunately CTrayNotify handles the visibility of the button, therefore this also fixes tab navigation when the button is hidden.
This commit is contained in:
Amrsatrio 2024-12-11 05:06:30 +07:00
parent 33c4611b4c
commit 1be66581c1

View File

@ -5047,6 +5047,23 @@ __declspec(dllexport) BOOL explorer_SetChildWindowNoActivateHook(HWND hWnd)
#pragma region "Hide Show desktop button" #pragma region "Hide Show desktop button"
#if WITH_MAIN_PATCHER #if WITH_MAIN_PATCHER
DWORD GetTaskbarSd()
{
DWORD dwVal = 1, dwSize = sizeof(DWORD);
if (SHRegGetValueFromHKCUHKLMFunc && SHRegGetValueFromHKCUHKLMFunc(
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
TEXT("TaskbarSd"),
SRRF_RT_REG_DWORD,
NULL,
&dwVal,
&dwSize
) == ERROR_SUCCESS)
{
return dwVal;
}
return 1; // Visible
}
INT64 ShowDesktopSubclassProc( INT64 ShowDesktopSubclassProc(
_In_ HWND hWnd, _In_ HWND hWnd,
_In_ UINT uMsg, _In_ UINT uMsg,
@ -5056,31 +5073,60 @@ INT64 ShowDesktopSubclassProc(
DWORD_PTR dwRefData DWORD_PTR dwRefData
) )
{ {
if (uMsg == WM_NCDESTROY) switch (uMsg)
{ {
RemoveWindowSubclass(hWnd, ShowDesktopSubclassProc, ShowDesktopSubclassProc); case WM_NCDESTROY:
}
else if (uMsg == WM_USER + 100)
{
LRESULT lRes = DefSubclassProc(hWnd, uMsg, wParam, lParam);
if (lRes > 0)
{ {
DWORD dwVal = 0, dwSize = sizeof(DWORD); RemoveWindowSubclass(hWnd, ShowDesktopSubclassProc, ShowDesktopSubclassProc);
if (SHRegGetValueFromHKCUHKLMFunc && SHRegGetValueFromHKCUHKLMFunc( break;
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), }
TEXT("TaskbarSd"), case WM_PAINT:
SRRF_RT_REG_DWORD, case WM_PRINTCLIENT:
NULL, {
&dwVal, HANDLE h_dwTaskbarSd = GetPropW(hWnd, L"EP_TaskbarSd");
(LPDWORD)(&dwSize) if (h_dwTaskbarSd)
) == ERROR_SUCCESS && !dwVal) {
{ DWORD dwTaskbarSd = (DWORD)h_dwTaskbarSd - 1;
lRes = 0; if (dwTaskbarSd == 2) // Invisible
} {
else if (dwVal) PostMessageW(hWnd, 794, 0, 0); PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
if (hdc)
{
HDC hdcPaint;
HPAINTBUFFER hBufferedPaint = BeginBufferedPaint(hdc, &ps.rcPaint, BPBF_TOPDOWNDIB, NULL, &hdcPaint);
if (hBufferedPaint)
{
if (IsThemeActive())
{
DrawThemeParentBackground(hWnd, hdcPaint, NULL);
}
else
{
RECT rc;
GetClientRect(hWnd, &rc);
FillRect(hdc, &rc, (HBRUSH)(COLOR_BTNFACE + 1));
}
EndBufferedPaint(hBufferedPaint, TRUE);
}
EndPaint(hWnd, &ps);
}
return 0;
}
}
break;
}
case WM_THEMECHANGED:
case WM_SETTINGCHANGE:
{
LRESULT lRes = DefSubclassProc(hWnd, uMsg, wParam, lParam);
DWORD dwTaskbarSd = GetTaskbarSd();
SetPropW(hWnd, L"EP_TaskbarSd", (HANDLE)(dwTaskbarSd + 1));
ShowWindow(hWnd, dwTaskbarSd != 0 ? SW_SHOW : SW_HIDE);
return lRes;
} }
return lRes;
} }
return DefSubclassProc(hWnd, uMsg, wParam, lParam); return DefSubclassProc(hWnd, uMsg, wParam, lParam);
} }
#endif #endif
@ -7295,13 +7341,6 @@ HTHEME explorer_OpenThemeDataForDpi(
} }
return hTheme; return hTheme;
} }
else if ((*((WORD*)&(pszClassList)+1)) && !wcscmp(pszClassList, L"TaskbarShowDesktop"))
{
DWORD dwVal = 0, dwSize = sizeof(DWORD);
RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"TaskbarSD", RRF_RT_REG_DWORD, NULL, &dwVal, &dwSize);
if (dwVal == 2) return NULL;
return OpenThemeDataForDpi(hwnd, pszClassList, dpi);
}
// task list - Taskband2 from CTaskListWnd::_HandleThemeChanged // task list - Taskband2 from CTaskListWnd::_HandleThemeChanged
if (bClassicThemeMitigations && (*((WORD*)&(pszClassList)+1)) && !wcscmp(pszClassList, L"Taskband2")) if (bClassicThemeMitigations && (*((WORD*)&(pszClassList)+1)) && !wcscmp(pszClassList, L"Taskband2"))