Skip to content

Commit 1be6658

Browse files
committed
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.
1 parent 33c4611 commit 1be6658

File tree

1 file changed

+65
-26
lines changed

1 file changed

+65
-26
lines changed

ExplorerPatcher/dllmain.c

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5047,6 +5047,23 @@ __declspec(dllexport) BOOL explorer_SetChildWindowNoActivateHook(HWND hWnd)
50475047

50485048
#pragma region "Hide Show desktop button"
50495049
#if WITH_MAIN_PATCHER
5050+
DWORD GetTaskbarSd()
5051+
{
5052+
DWORD dwVal = 1, dwSize = sizeof(DWORD);
5053+
if (SHRegGetValueFromHKCUHKLMFunc && SHRegGetValueFromHKCUHKLMFunc(
5054+
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
5055+
TEXT("TaskbarSd"),
5056+
SRRF_RT_REG_DWORD,
5057+
NULL,
5058+
&dwVal,
5059+
&dwSize
5060+
) == ERROR_SUCCESS)
5061+
{
5062+
return dwVal;
5063+
}
5064+
return 1; // Visible
5065+
}
5066+
50505067
INT64 ShowDesktopSubclassProc(
50515068
_In_ HWND hWnd,
50525069
_In_ UINT uMsg,
@@ -5056,31 +5073,60 @@ INT64 ShowDesktopSubclassProc(
50565073
DWORD_PTR dwRefData
50575074
)
50585075
{
5059-
if (uMsg == WM_NCDESTROY)
5060-
{
5061-
RemoveWindowSubclass(hWnd, ShowDesktopSubclassProc, ShowDesktopSubclassProc);
5062-
}
5063-
else if (uMsg == WM_USER + 100)
5076+
switch (uMsg)
50645077
{
5065-
LRESULT lRes = DefSubclassProc(hWnd, uMsg, wParam, lParam);
5066-
if (lRes > 0)
5078+
case WM_NCDESTROY:
50675079
{
5068-
DWORD dwVal = 0, dwSize = sizeof(DWORD);
5069-
if (SHRegGetValueFromHKCUHKLMFunc && SHRegGetValueFromHKCUHKLMFunc(
5070-
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
5071-
TEXT("TaskbarSd"),
5072-
SRRF_RT_REG_DWORD,
5073-
NULL,
5074-
&dwVal,
5075-
(LPDWORD)(&dwSize)
5076-
) == ERROR_SUCCESS && !dwVal)
5080+
RemoveWindowSubclass(hWnd, ShowDesktopSubclassProc, ShowDesktopSubclassProc);
5081+
break;
5082+
}
5083+
case WM_PAINT:
5084+
case WM_PRINTCLIENT:
5085+
{
5086+
HANDLE h_dwTaskbarSd = GetPropW(hWnd, L"EP_TaskbarSd");
5087+
if (h_dwTaskbarSd)
50775088
{
5078-
lRes = 0;
5089+
DWORD dwTaskbarSd = (DWORD)h_dwTaskbarSd - 1;
5090+
if (dwTaskbarSd == 2) // Invisible
5091+
{
5092+
PAINTSTRUCT ps;
5093+
HDC hdc = BeginPaint(hWnd, &ps);
5094+
if (hdc)
5095+
{
5096+
HDC hdcPaint;
5097+
HPAINTBUFFER hBufferedPaint = BeginBufferedPaint(hdc, &ps.rcPaint, BPBF_TOPDOWNDIB, NULL, &hdcPaint);
5098+
if (hBufferedPaint)
5099+
{
5100+
if (IsThemeActive())
5101+
{
5102+
DrawThemeParentBackground(hWnd, hdcPaint, NULL);
5103+
}
5104+
else
5105+
{
5106+
RECT rc;
5107+
GetClientRect(hWnd, &rc);
5108+
FillRect(hdc, &rc, (HBRUSH)(COLOR_BTNFACE + 1));
5109+
}
5110+
EndBufferedPaint(hBufferedPaint, TRUE);
5111+
}
5112+
EndPaint(hWnd, &ps);
5113+
}
5114+
return 0;
5115+
}
50795116
}
5080-
else if (dwVal) PostMessageW(hWnd, 794, 0, 0);
5117+
break;
5118+
}
5119+
case WM_THEMECHANGED:
5120+
case WM_SETTINGCHANGE:
5121+
{
5122+
LRESULT lRes = DefSubclassProc(hWnd, uMsg, wParam, lParam);
5123+
DWORD dwTaskbarSd = GetTaskbarSd();
5124+
SetPropW(hWnd, L"EP_TaskbarSd", (HANDLE)(dwTaskbarSd + 1));
5125+
ShowWindow(hWnd, dwTaskbarSd != 0 ? SW_SHOW : SW_HIDE);
5126+
return lRes;
50815127
}
5082-
return lRes;
50835128
}
5129+
50845130
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
50855131
}
50865132
#endif
@@ -7295,13 +7341,6 @@ HTHEME explorer_OpenThemeDataForDpi(
72957341
}
72967342
return hTheme;
72977343
}
7298-
else if ((*((WORD*)&(pszClassList)+1)) && !wcscmp(pszClassList, L"TaskbarShowDesktop"))
7299-
{
7300-
DWORD dwVal = 0, dwSize = sizeof(DWORD);
7301-
RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"TaskbarSD", RRF_RT_REG_DWORD, NULL, &dwVal, &dwSize);
7302-
if (dwVal == 2) return NULL;
7303-
return OpenThemeDataForDpi(hwnd, pszClassList, dpi);
7304-
}
73057344

73067345
// task list - Taskband2 from CTaskListWnd::_HandleThemeChanged
73077346
if (bClassicThemeMitigations && (*((WORD*)&(pszClassList)+1)) && !wcscmp(pszClassList, L"Taskband2"))

0 commit comments

Comments
 (0)