From 0e8cf6ffd58cc7a46db8bfe46cfb361aceb15153 Mon Sep 17 00:00:00 2001 From: "Carl J. Bialorucki" Date: Sat, 22 Jul 2023 09:24:28 -0600 Subject: [PATCH] [EXPLORER] Large taskbar icon support (#5465) - Use HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarSmallIcons registry key to store the icon size setting for the taskbar. - If the registry value is missing, small icons will be used by default. - If the registry value is set to 1, it will also use small icons. - Only if the value exists and is set to 0 it will use large icons. This allows us to use the same registry value as Windows 7 explorer, while also keeping the taskbar icons small in most cases, especially running the shell on unmodified Windows Server 2003. CORE-11698 --- base/shell/explorer/precomp.h | 1 + base/shell/explorer/settings.cpp | 4 ++++ base/shell/explorer/taskswnd.cpp | 15 ++++++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/base/shell/explorer/precomp.h b/base/shell/explorer/precomp.h index 7f58465ad8e..91770090ef5 100644 --- a/base/shell/explorer/precomp.h +++ b/base/shell/explorer/precomp.h @@ -210,6 +210,7 @@ struct TaskbarSettings BOOL bShowSeconds; BOOL bPreferDate; BOOL bHideInactiveIcons; + BOOL bSmallIcons; TW_STRUCKRECTS2 sr; BOOL Load(); diff --git a/base/shell/explorer/settings.cpp b/base/shell/explorer/settings.cpp index 9e6051eb9d7..4c6b3dd2633 100644 --- a/base/shell/explorer/settings.cpp +++ b/base/shell/explorer/settings.cpp @@ -31,6 +31,7 @@ BOOL TaskbarSettings::Save() BOOL bAllowSizeMove = !bLock; SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", REG_DWORD, &bAllowSizeMove, sizeof(bAllowSizeMove)); sr.cbSize = sizeof(sr); + SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSmallIcons", REG_DWORD, &bSmallIcons, sizeof(bSmallIcons)); SHSetValueW(hkExplorer, L"StuckRects2", L"Settings", REG_BINARY, &sr, sizeof(sr)); /* TODO: AutoHide writes something to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0 figure out what and why */ @@ -57,6 +58,9 @@ BOOL TaskbarSettings::Load() dwRet = SHGetValueW(hkExplorer, NULL, L"EnableAutotray", NULL, &dwValue, &cbSize); bHideInactiveIcons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE; + dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarSmallIcons", NULL, &dwValue, &cbSize); + bSmallIcons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : TRUE; + cbSize = sizeof(sr); dwRet = SHGetValueW(hkExplorer, L"StuckRects2", L"Settings", NULL, &sr, &cbSize); diff --git a/base/shell/explorer/taskswnd.cpp b/base/shell/explorer/taskswnd.cpp index 5437f4701f0..e58c99bc6df 100644 --- a/base/shell/explorer/taskswnd.cpp +++ b/base/shell/explorer/taskswnd.cpp @@ -494,7 +494,7 @@ public: #define GET_ICON(type) \ SendMessageTimeout(hwnd, WM_GETICON, (type), 0, SMTO_NOTIMEOUTIFNOTHUNG, 100, (PDWORD_PTR)&hIcon) - LRESULT bAlive = GET_ICON(ICON_SMALL2); + LRESULT bAlive = GET_ICON(g_TaskbarSettings.bSmallIcons ? ICON_SMALL2 : ICON_BIG); if (hIcon) return hIcon; @@ -507,7 +507,7 @@ public: if (bAlive) { - GET_ICON(ICON_BIG); + GET_ICON(g_TaskbarSettings.bSmallIcons ? ICON_BIG : ICON_SMALL2); if (hIcon) return hIcon; } @@ -1262,9 +1262,12 @@ public: /* Update the size of the image list if needed */ int cx, cy; ImageList_GetIconSize(m_ImageList, &cx, &cy); - if (cx != GetSystemMetrics(SM_CXSMICON) || cy != GetSystemMetrics(SM_CYSMICON)) + if (cx != GetSystemMetrics(g_TaskbarSettings.bSmallIcons ? SM_CXSMICON : SM_CXICON) || + cy != GetSystemMetrics(g_TaskbarSettings.bSmallIcons ? SM_CYSMICON : SM_CYICON)) { - ImageList_SetIconSize(m_ImageList, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); + ImageList_SetIconSize(m_ImageList, + GetSystemMetrics(g_TaskbarSettings.bSmallIcons ? SM_CXSMICON : SM_CXICON), + GetSystemMetrics(g_TaskbarSettings.bSmallIcons ? SM_CYSMICON : SM_CYICON)); /* SetIconSize removes all icons so we have to reinsert them */ PTASK_ITEM TaskItem = m_TaskItems; @@ -1430,7 +1433,9 @@ public: SetWindowTheme(m_TaskBar.m_hWnd, L"TaskBand", NULL); - m_ImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 1000); + m_ImageList = ImageList_Create(GetSystemMetrics(g_TaskbarSettings.bSmallIcons ? SM_CXSMICON : SM_CXICON), + GetSystemMetrics(g_TaskbarSettings.bSmallIcons ? SM_CYSMICON : SM_CYICON), + ILC_COLOR32 | ILC_MASK, 0, 1000); m_TaskBar.SetImageList(m_ImageList); /* Set proper spacing between buttons */