[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
This commit is contained in:
Carl J. Bialorucki 2023-07-22 09:24:28 -06:00 committed by GitHub
parent 6d37456542
commit 0e8cf6ffd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View file

@ -210,6 +210,7 @@ struct TaskbarSettings
BOOL bShowSeconds; BOOL bShowSeconds;
BOOL bPreferDate; BOOL bPreferDate;
BOOL bHideInactiveIcons; BOOL bHideInactiveIcons;
BOOL bSmallIcons;
TW_STRUCKRECTS2 sr; TW_STRUCKRECTS2 sr;
BOOL Load(); BOOL Load();

View file

@ -31,6 +31,7 @@ BOOL TaskbarSettings::Save()
BOOL bAllowSizeMove = !bLock; BOOL bAllowSizeMove = !bLock;
SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", REG_DWORD, &bAllowSizeMove, sizeof(bAllowSizeMove)); SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", REG_DWORD, &bAllowSizeMove, sizeof(bAllowSizeMove));
sr.cbSize = sizeof(sr); 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)); 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 */ /* 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); dwRet = SHGetValueW(hkExplorer, NULL, L"EnableAutotray", NULL, &dwValue, &cbSize);
bHideInactiveIcons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE; 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); cbSize = sizeof(sr);
dwRet = SHGetValueW(hkExplorer, L"StuckRects2", L"Settings", NULL, &sr, &cbSize); dwRet = SHGetValueW(hkExplorer, L"StuckRects2", L"Settings", NULL, &sr, &cbSize);

View file

@ -494,7 +494,7 @@ public:
#define GET_ICON(type) \ #define GET_ICON(type) \
SendMessageTimeout(hwnd, WM_GETICON, (type), 0, SMTO_NOTIMEOUTIFNOTHUNG, 100, (PDWORD_PTR)&hIcon) 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) if (hIcon)
return hIcon; return hIcon;
@ -507,7 +507,7 @@ public:
if (bAlive) if (bAlive)
{ {
GET_ICON(ICON_BIG); GET_ICON(g_TaskbarSettings.bSmallIcons ? ICON_BIG : ICON_SMALL2);
if (hIcon) if (hIcon)
return hIcon; return hIcon;
} }
@ -1262,9 +1262,12 @@ public:
/* Update the size of the image list if needed */ /* Update the size of the image list if needed */
int cx, cy; int cx, cy;
ImageList_GetIconSize(m_ImageList, &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 */ /* SetIconSize removes all icons so we have to reinsert them */
PTASK_ITEM TaskItem = m_TaskItems; PTASK_ITEM TaskItem = m_TaskItems;
@ -1430,7 +1433,9 @@ public:
SetWindowTheme(m_TaskBar.m_hWnd, L"TaskBand", NULL); 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); m_TaskBar.SetImageList(m_ImageList);
/* Set proper spacing between buttons */ /* Set proper spacing between buttons */