Skip to content

Commit b6f5402

Browse files
committed
Fix taskbar texture on Windows 11
- Taskbar is now handled by taskbar.dll, so we need to hook APIs there - TaskList window (MSTaskListWClass) is not visible so we need to hook messages of its parent TaskBand window (MSTaskSwWClass) Fixes #1230
1 parent de0d6cf commit b6f5402

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,21 @@ static LRESULT CALLBACK SubclassTaskBarProc( HWND hWnd, UINT uMsg, WPARAM wParam
20392039

20402040
static LRESULT CALLBACK SubclassTaskListProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
20412041
{
2042+
if (uMsg==WM_PAINT && g_TaskbarTexture)
2043+
{
2044+
wchar_t name[100];
2045+
GetClassName(hWnd,name,_countof(name));
2046+
if (_wcsicmp(name,L"MSTaskSwWClass")==0)
2047+
{
2048+
// draw taskbar background (behind task list)
2049+
PAINTSTRUCT ps;
2050+
HDC hdc=BeginPaint(hWnd,&ps);
2051+
DrawThemeParentBackground(hWnd,hdc,NULL);
2052+
EndPaint(hWnd,&ps);
2053+
return 0;
2054+
}
2055+
}
2056+
20422057
if (uMsg==WM_PAINT || uMsg==WM_PRINT || uMsg==WM_PRINTCLIENT)
20432058
{
20442059
g_CurrentTaskList=hWnd;
@@ -2880,6 +2895,10 @@ static void InitStartMenuDLL( void )
28802895

28812896
if (GetSettingBool(L"CustomTaskbar"))
28822897
{
2898+
auto module=GetModuleHandle(L"taskbar.dll");
2899+
if (!module)
2900+
module=GetModuleHandle(NULL);
2901+
28832902
if (GetWinVersion()>=WIN_VER_WIN10)
28842903
{
28852904
HMODULE shlwapi=GetModuleHandle(L"shlwapi.dll");
@@ -2888,12 +2907,14 @@ static void InitStartMenuDLL( void )
28882907
g_SHFillRectClr=(tSHFillRectClr)GetProcAddress(shlwapi,MAKEINTRESOURCEA(197));
28892908
if (g_SHFillRectClr)
28902909
{
2891-
g_SHFillRectClrHook=SetIatHook(GetModuleHandle(NULL),"shlwapi.dll",MAKEINTRESOURCEA(197),SHFillRectClr2);
2910+
g_SHFillRectClrHook=SetIatHook(module,"shlwapi.dll",MAKEINTRESOURCEA(197),SHFillRectClr2);
28922911
if (!g_SHFillRectClrHook)
2893-
g_SHFillRectClrHook=SetIatHook(GetModuleHandle(NULL),"api-ms-win-shlwapi-winrt-storage-l1-1-1.dll",MAKEINTRESOURCEA(197),SHFillRectClr2);
2912+
g_SHFillRectClrHook=SetIatHook(module,"api-ms-win-shlwapi-winrt-storage-l1-1-1.dll",MAKEINTRESOURCEA(197),SHFillRectClr2);
28942913
}
28952914
}
2896-
g_StretchDIBitsHook=SetIatHook(GetModuleHandle(NULL),"gdi32.dll","StretchDIBits",StretchDIBits2);
2915+
g_StretchDIBitsHook=SetIatHook(module,"gdi32.dll","StretchDIBits",StretchDIBits2);
2916+
if (!g_StretchDIBitsHook)
2917+
g_StretchDIBitsHook=SetIatHook(module,"ext-ms-win-gdi-draw-l1-1-0.dll","StretchDIBits",StretchDIBits2);
28972918
}
28982919

28992920
{
@@ -2903,12 +2924,12 @@ static void InitStartMenuDLL( void )
29032924
}
29042925

29052926
if (GetWinVersion()<=WIN_VER_WIN81)
2906-
g_DrawThemeBackgroundHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeBackground",DrawThemeBackground2);
2907-
g_DrawThemeTextHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeText",DrawThemeText2);
2908-
g_DrawThemeTextExHook=SetIatHook(GetModuleHandle(NULL),"uxtheme.dll","DrawThemeTextEx",DrawThemeTextEx2);
2927+
g_DrawThemeBackgroundHook=SetIatHook(module,"uxtheme.dll","DrawThemeBackground",DrawThemeBackground2);
2928+
g_DrawThemeTextHook=SetIatHook(module,"uxtheme.dll","DrawThemeText",DrawThemeText2);
2929+
g_DrawThemeTextExHook=SetIatHook(module,"uxtheme.dll","DrawThemeTextEx",DrawThemeTextEx2);
29092930
g_DrawThemeTextCtlHook=SetIatHook(GetModuleHandle(L"comctl32.dll"),"uxtheme.dll","DrawThemeText",DrawThemeText2);
29102931
if (GetWinVersion()>=WIN_VER_WIN10)
2911-
g_SetWindowCompositionAttributeHook=SetIatHook(GetModuleHandle(NULL),"user32.dll","SetWindowCompositionAttribute",SetWindowCompositionAttribute2);
2932+
g_SetWindowCompositionAttributeHook=SetIatHook(module,"user32.dll","SetWindowCompositionAttribute",SetWindowCompositionAttribute2);
29122933
}
29132934

29142935
g_TaskbarThreadId=GetCurrentThreadId();
@@ -2947,9 +2968,18 @@ static void InitStartMenuDLL( void )
29472968
if (taskBar.rebar)
29482969
{
29492970
SetWindowSubclass(taskBar.rebar,SubclassRebarProc,'CLSH',taskbarId);
2971+
// TaskBand window
29502972
HWND hwnd=FindWindowEx(taskBar.rebar,NULL,L"MSTaskSwWClass",NULL);
29512973
if (hwnd)
2952-
taskBar.taskList=FindWindowEx(hwnd,NULL,L"MSTaskListWClass",NULL);
2974+
{
2975+
taskBar.taskList=hwnd;
2976+
// TaskList window
2977+
// it has to be visible, otherwise it won't receive WM_PAINT that we need to intercept
2978+
// in such case we will intercept parent instead
2979+
hwnd=FindWindowEx(hwnd,NULL,L"MSTaskListWClass",NULL);
2980+
if (hwnd&&IsWindowVisible(hwnd))
2981+
taskBar.taskList=hwnd;
2982+
}
29532983
if (taskBar.taskList)
29542984
SetWindowSubclass(taskBar.taskList,SubclassTaskListProc,'CLSH',taskbarId);
29552985
}

0 commit comments

Comments
 (0)