Browse Source

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.
pull/4071/head
Amrsatrio 1 year ago
parent
commit
1be66581c1
  1. 83
      ExplorerPatcher/dllmain.c

83
ExplorerPatcher/dllmain.c

@ -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)
{
case WM_NCDESTROY:
{ {
RemoveWindowSubclass(hWnd, ShowDesktopSubclassProc, ShowDesktopSubclassProc); RemoveWindowSubclass(hWnd, ShowDesktopSubclassProc, ShowDesktopSubclassProc);
break;
} }
else if (uMsg == WM_USER + 100) case WM_PAINT:
case WM_PRINTCLIENT:
{ {
LRESULT lRes = DefSubclassProc(hWnd, uMsg, wParam, lParam); HANDLE h_dwTaskbarSd = GetPropW(hWnd, L"EP_TaskbarSd");
if (lRes > 0) if (h_dwTaskbarSd)
{ {
DWORD dwVal = 0, dwSize = sizeof(DWORD); DWORD dwTaskbarSd = (DWORD)h_dwTaskbarSd - 1;
if (SHRegGetValueFromHKCUHKLMFunc && SHRegGetValueFromHKCUHKLMFunc( if (dwTaskbarSd == 2) // Invisible
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), {
TEXT("TaskbarSd"), PAINTSTRUCT ps;
SRRF_RT_REG_DWORD, HDC hdc = BeginPaint(hWnd, &ps);
NULL, if (hdc)
&dwVal,
(LPDWORD)(&dwSize)
) == ERROR_SUCCESS && !dwVal)
{ {
lRes = 0; HDC hdcPaint;
HPAINTBUFFER hBufferedPaint = BeginBufferedPaint(hdc, &ps.rcPaint, BPBF_TOPDOWNDIB, NULL, &hdcPaint);
if (hBufferedPaint)
{
if (IsThemeActive())
{
DrawThemeParentBackground(hWnd, hdcPaint, NULL);
} }
else if (dwVal) PostMessageW(hWnd, 794, 0, 0); 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"))

Loading…
Cancel
Save