[EXPLORER] Set icon size and show or hide desktop button from taskbar properties (#5510)

CORE-11698, CORE-15369

Allows a user to set the icon size and show or hide the desktop button in
the taskbar using the taskbar properties menu. After applying these changes,
the taskbar updates and resizes without requiring a restart.

- This PR moves the 'Notification Area' section into its own separate tab.
  This allows us to include more options for users without increasing the
  size of the window. It is also very similar to the Windows Vista taskbar
  properties menu.

- Some minor changes to allow the taskbar to refresh its view when the icon
  size or show desktop button setting changes.
This commit is contained in:
Carl J. Bialorucki 2023-08-10 09:06:55 -06:00 committed by GitHub
parent 984284c436
commit 28ae9fb738
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 787 additions and 353 deletions

View file

@ -48,24 +48,17 @@ class CTaskBarSettingsPage : public CPropertyPageImpl<CTaskBarSettingsPage>
{
private:
HBITMAP m_hbmpTaskbar;
HBITMAP m_hbmpTray;
HWND m_hwndTaskbar;
void UpdateDialog()
void _UpdateDialog()
{
BOOL bLock = IsDlgButtonChecked(IDC_TASKBARPROP_LOCK);
BOOL bHide = IsDlgButtonChecked(IDC_TASKBARPROP_HIDE);
BOOL bGroup = IsDlgButtonChecked(IDC_TASKBARPROP_GROUP);
BOOL bShowQL = IsDlgButtonChecked(IDC_TASKBARPROP_SHOWQL);
BOOL bShowClock = IsDlgButtonChecked(IDC_TASKBARPROP_CLOCK);
BOOL bShowSeconds = IsDlgButtonChecked(IDC_TASKBARPROP_SECONDS);
BOOL bHideInactive = IsDlgButtonChecked(IDC_TASKBARPROP_HIDEICONS);
UINT uImageId;
HWND hwndCustomizeNotifyButton = GetDlgItem(IDC_TASKBARPROP_ICONCUST);
HWND hwndSeconds = GetDlgItem(IDC_TASKBARPROP_SECONDS);
HWND hwndTaskbarBitmap = GetDlgItem(IDC_TASKBARPROP_TASKBARBITMAP);
HWND hwndTrayBitmap = GetDlgItem(IDC_TASKBARPROP_NOTIFICATIONBITMAP);
if (bHide)
uImageId = IDB_TASKBARPROP_AUTOHIDE;
@ -85,32 +78,8 @@ private:
uImageId = IDB_TASKBARPROP_NOLOCK_NOGROUP_QL;
else if (!bLock && bGroup && bShowQL)
uImageId = IDB_TASKBARPROP_NOLOCK_GROUP_QL;
else
ASSERT(FALSE);
SetBitmap(hwndTaskbarBitmap, &m_hbmpTaskbar, uImageId);
::EnableWindow(hwndCustomizeNotifyButton, bHideInactive);
::EnableWindow(hwndSeconds, bShowClock);
if (!bShowSeconds)
CheckDlgButton(IDC_TASKBARPROP_SECONDS, BST_UNCHECKED);
if (bHideInactive && bShowClock && bShowSeconds)
uImageId = IDB_SYSTRAYPROP_HIDE_SECONDS;
else if (bHideInactive && bShowClock && !bShowSeconds)
uImageId = IDB_SYSTRAYPROP_HIDE_CLOCK;
else if (bHideInactive && !bShowClock)
uImageId = IDB_SYSTRAYPROP_HIDE_NOCLOCK;
else if (!bHideInactive && bShowClock && bShowSeconds)
uImageId = IDB_SYSTRAYPROP_SHOW_SECONDS;
else if (!bHideInactive && bShowClock && !bShowSeconds)
uImageId = IDB_SYSTRAYPROP_SHOW_CLOCK;
else if (!bHideInactive && !bShowClock)
uImageId = IDB_SYSTRAYPROP_SHOW_NOCLOCK;
else
ASSERT(FALSE);
SetBitmap(hwndTrayBitmap, &m_hbmpTray, uImageId);
}
public:
@ -118,14 +87,12 @@ public:
BEGIN_MSG_MAP(CTaskBarSettingsPage)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDC_TASKBARPROP_ICONCUST, OnCustomizeTrayIcons)
COMMAND_RANGE_HANDLER(IDC_TASKBARPROP_FIRST_CMD, IDC_TASKBARPROP_LAST_CMD, OnCtrlCommand)
CHAIN_MSG_MAP(CPropertyPageImpl<CTaskBarSettingsPage>)
END_MSG_MAP()
CTaskBarSettingsPage(HWND hwnd):
m_hbmpTaskbar(NULL),
m_hbmpTray(NULL),
m_hwndTaskbar(hwnd)
{
}
@ -134,8 +101,6 @@ public:
{
if (m_hbmpTaskbar)
DeleteObject(m_hbmpTaskbar);
if (m_hbmpTray)
DeleteObject(m_hbmpTray);
}
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
@ -145,40 +110,29 @@ public:
CheckDlgButton(IDC_TASKBARPROP_ONTOP, g_TaskbarSettings.sr.AlwaysOnTop ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_TASKBARPROP_GROUP, g_TaskbarSettings.bGroupButtons ? BST_CHECKED : BST_UNCHECKED);
//CheckDlgButton(IDC_TASKBARPROP_SHOWQL, g_TaskbarSettings.bShowQuickLaunch ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_TASKBARPROP_CLOCK, (!g_TaskbarSettings.sr.HideClock) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_TASKBARPROP_SECONDS, g_TaskbarSettings.bShowSeconds ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_TASKBARPROP_HIDEICONS, g_TaskbarSettings.bHideInactiveIcons ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_TASKBARPROP_SMALLICONS, g_TaskbarSettings.bSmallIcons ? BST_CHECKED : BST_UNCHECKED);
UpdateDialog();
_UpdateDialog();
return TRUE;
}
LRESULT OnCustomizeTrayIcons(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
{
ShowCustomizeNotifyIcons(hExplorerInstance, m_hWnd);
return 0;
}
LRESULT OnCtrlCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
{
UpdateDialog();
_UpdateDialog();
SetModified(TRUE);
return 0;
}
int OnApply()
{
TaskbarSettings newSettings;
memcpy(&newSettings, &g_TaskbarSettings, sizeof(TaskbarSettings));
TaskbarSettings newSettings = g_TaskbarSettings;
newSettings.bLock = IsDlgButtonChecked(IDC_TASKBARPROP_LOCK);
newSettings.sr.AutoHide = IsDlgButtonChecked(IDC_TASKBARPROP_HIDE);
newSettings.sr.AlwaysOnTop = IsDlgButtonChecked(IDC_TASKBARPROP_ONTOP);
newSettings.bGroupButtons = IsDlgButtonChecked(IDC_TASKBARPROP_GROUP);
//newSettings.bShowQuickLaunch = IsDlgButtonChecked(IDC_TASKBARPROP_SHOWQL);
newSettings.sr.HideClock = !IsDlgButtonChecked(IDC_TASKBARPROP_CLOCK);
newSettings.bShowSeconds = IsDlgButtonChecked(IDC_TASKBARPROP_SECONDS);
newSettings.bHideInactiveIcons = IsDlgButtonChecked(IDC_TASKBARPROP_HIDEICONS);
newSettings.bSmallIcons = IsDlgButtonChecked(IDC_TASKBARPROP_SMALLICONS);
SendMessage(m_hwndTaskbar, TWM_SETTINGSCHANGED, 0, (LPARAM)&newSettings);
@ -191,7 +145,7 @@ class CStartMenuSettingsPage : public CPropertyPageImpl<CStartMenuSettingsPage>
private:
HBITMAP m_hbmpStartBitmap;
void UpdateDialog()
void _UpdateDialog()
{
HWND hwndCustomizeClassic = GetDlgItem(IDC_TASKBARPROP_STARTMENUCLASSICCUST);
HWND hwndCustomizeModern = GetDlgItem(IDC_TASKBARPROP_STARTMENUCUST);
@ -252,7 +206,7 @@ public:
{
// fix me: start menu style (classic/modern) should be read somewhere from the registry.
CheckDlgButton(IDC_TASKBARPROP_STARTMENUCLASSIC, BST_CHECKED); // HACK: This has to be read from registry!!!!!!!
UpdateDialog();
_UpdateDialog();
return TRUE;
}
@ -270,6 +224,105 @@ public:
}
};
class CNotifySettingsPage : public CPropertyPageImpl<CNotifySettingsPage>
{
private:
HBITMAP m_hbmpTray;
HWND m_hwndTaskbar;
void _UpdateDialog()
{
BOOL bShowClock = IsDlgButtonChecked(IDC_TASKBARPROP_CLOCK);
BOOL bShowSeconds = IsDlgButtonChecked(IDC_TASKBARPROP_SECONDS);
BOOL bHideInactive = IsDlgButtonChecked(IDC_TASKBARPROP_HIDEICONS);
UINT uImageId;
HWND hwndCustomizeNotifyButton = GetDlgItem(IDC_TASKBARPROP_ICONCUST);
HWND hwndSeconds = GetDlgItem(IDC_TASKBARPROP_SECONDS);
HWND hwndTrayBitmap = GetDlgItem(IDC_TASKBARPROP_NOTIFICATIONBITMAP);
::EnableWindow(hwndCustomizeNotifyButton, bHideInactive);
::EnableWindow(hwndSeconds, bShowClock);
if (!bShowSeconds)
CheckDlgButton(IDC_TASKBARPROP_SECONDS, BST_UNCHECKED);
if (bHideInactive && bShowClock && bShowSeconds)
uImageId = IDB_SYSTRAYPROP_HIDE_SECONDS;
else if (bHideInactive && bShowClock && !bShowSeconds)
uImageId = IDB_SYSTRAYPROP_HIDE_CLOCK;
else if (bHideInactive && !bShowClock)
uImageId = IDB_SYSTRAYPROP_HIDE_NOCLOCK;
else if (!bHideInactive && bShowClock && bShowSeconds)
uImageId = IDB_SYSTRAYPROP_SHOW_SECONDS;
else if (!bHideInactive && bShowClock && !bShowSeconds)
uImageId = IDB_SYSTRAYPROP_SHOW_CLOCK;
else if (!bHideInactive && !bShowClock)
uImageId = IDB_SYSTRAYPROP_SHOW_NOCLOCK;
SetBitmap(hwndTrayBitmap, &m_hbmpTray, uImageId);
}
public:
enum { IDD = IDD_TASKBARPROP_NOTIFY };
BEGIN_MSG_MAP(CNotifySettingsPage)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDC_TASKBARPROP_ICONCUST, OnCustomizeTrayIcons)
COMMAND_RANGE_HANDLER(IDC_TASKBARPROP_NOTIFY_FIRST_CMD, IDC_TASKBARPROP_NOTIFY_LAST_CMD, OnCtrlCommand)
CHAIN_MSG_MAP(CPropertyPageImpl<CNotifySettingsPage>)
END_MSG_MAP()
CNotifySettingsPage(HWND hwnd):
m_hbmpTray(NULL),
m_hwndTaskbar(hwnd)
{
}
~CNotifySettingsPage()
{
if (m_hbmpTray)
DeleteObject(m_hbmpTray);
}
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
CheckDlgButton(IDC_TASKBARPROP_CLOCK, (!g_TaskbarSettings.sr.HideClock) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_TASKBARPROP_SECONDS, g_TaskbarSettings.bShowSeconds ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_TASKBARPROP_HIDEICONS, g_TaskbarSettings.bHideInactiveIcons ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_TASKBARPROP_DESKTOP, g_TaskbarSettings.bShowDesktopButton ? BST_CHECKED : BST_UNCHECKED);
_UpdateDialog();
return TRUE;
}
LRESULT OnCustomizeTrayIcons(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
{
ShowCustomizeNotifyIcons(hExplorerInstance, m_hWnd);
return 0;
}
LRESULT OnCtrlCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
{
_UpdateDialog();
SetModified(TRUE);
return 0;
}
int OnApply()
{
TaskbarSettings newSettings = g_TaskbarSettings;
newSettings.sr.HideClock = !IsDlgButtonChecked(IDC_TASKBARPROP_CLOCK);
newSettings.bShowSeconds = IsDlgButtonChecked(IDC_TASKBARPROP_SECONDS);
newSettings.bHideInactiveIcons = IsDlgButtonChecked(IDC_TASKBARPROP_HIDEICONS);
newSettings.bShowDesktopButton = IsDlgButtonChecked(IDC_TASKBARPROP_DESKTOP);
SendMessage(m_hwndTaskbar, TWM_SETTINGSCHANGED, 0, (LPARAM)&newSettings);
return PSNRET_NOERROR;
}
};
static int CALLBACK
PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
{
@ -291,15 +344,17 @@ VOID
DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar)
{
PROPSHEETHEADER psh;
HPROPSHEETPAGE hpsp[2];
CSimpleArray<HPROPSHEETPAGE> hpsp;
CTaskBarSettingsPage tbSettingsPage(hwndTaskbar);
CStartMenuSettingsPage smSettingsPage;
CNotifySettingsPage naSettingsPage(hwndTaskbar);
CStringW caption;
caption.LoadStringW(IDS_TASKBAR_STARTMENU_PROP_CAPTION);
hpsp[0] = tbSettingsPage.Create();
hpsp[1] = smSettingsPage.Create();
hpsp.Add(tbSettingsPage.Create());
hpsp.Add(smSettingsPage.Create());
hpsp.Add(naSettingsPage.Create());
ZeroMemory(&psh, sizeof(psh));
psh.dwSize = sizeof(psh);
@ -308,9 +363,9 @@ DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar)
psh.hInstance = hExplorerInstance;
psh.pszIcon = MAKEINTRESOURCEW(IDI_STARTMENU);
psh.pszCaption = caption.GetString();
psh.nPages = _countof(hpsp);
psh.nPages = hpsp.GetSize();
psh.nStartPage = 0;
psh.phpage = hpsp;
psh.phpage = hpsp.GetData();
psh.pfnCallback = PropSheetProc;
PropertySheet(&psh);