Skip to content

Commit

Permalink
[EXPLORER] Large taskbar icon support (#5465)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
cbialorucki committed Jul 22, 2023
1 parent 6d37456 commit 0e8cf6f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions base/shell/explorer/precomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ struct TaskbarSettings
BOOL bShowSeconds;
BOOL bPreferDate;
BOOL bHideInactiveIcons;
BOOL bSmallIcons;
TW_STRUCKRECTS2 sr;

BOOL Load();
Expand Down
4 changes: 4 additions & 0 deletions base/shell/explorer/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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);

Expand Down
15 changes: 10 additions & 5 deletions base/shell/explorer/taskswnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class CTaskSwitchWnd :
#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;

Expand All @@ -507,7 +507,7 @@ class CTaskSwitchWnd :

if (bAlive)
{
GET_ICON(ICON_BIG);
GET_ICON(g_TaskbarSettings.bSmallIcons ? ICON_BIG : ICON_SMALL2);
if (hIcon)
return hIcon;
}
Expand Down Expand Up @@ -1262,9 +1262,12 @@ class CTaskSwitchWnd :
/* 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;
Expand Down Expand Up @@ -1430,7 +1433,9 @@ class CTaskSwitchWnd :

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 */
Expand Down

0 comments on commit 0e8cf6f

Please sign in to comment.