mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:45:46 +00:00
[STOBJECT] Store the "Show x icon in the taskbar" setting for the hotplug, power and volume icons.
CORE-12365 CORE-12972 CORE-15234
This commit is contained in:
parent
22411ef223
commit
8c30fdab1c
6 changed files with 128 additions and 36 deletions
|
@ -13,15 +13,80 @@
|
|||
#include <shellutils.h>
|
||||
|
||||
SysTrayIconHandlers_t g_IconHandlers [] = {
|
||||
{ Volume_Init, Volume_Shutdown, Volume_Update, Volume_Message },
|
||||
{ Hotplug_Init, Hotplug_Shutdown, Hotplug_Update, Hotplug_Message },
|
||||
{ Power_Init, Power_Shutdown, Power_Update, Power_Message }
|
||||
{ VOLUME_SERVICE_FLAG, Volume_Init, Volume_Shutdown, Volume_Update, Volume_Message },
|
||||
{ HOTPLUG_SERVICE_FLAG, Hotplug_Init, Hotplug_Shutdown, Hotplug_Update, Hotplug_Message },
|
||||
{ POWER_SERVICE_FLAG, Power_Init, Power_Shutdown, Power_Update, Power_Message }
|
||||
};
|
||||
const int g_NumIcons = _countof(g_IconHandlers);
|
||||
|
||||
CSysTray::CSysTray() {}
|
||||
CSysTray::~CSysTray() {}
|
||||
|
||||
VOID CSysTray::GetServicesEnabled()
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD dwSize;
|
||||
|
||||
/* Enable power and volume by default */
|
||||
this->dwServicesEnabled = POWER_SERVICE_FLAG | VOLUME_SERVICE_FLAG;
|
||||
|
||||
if (RegCreateKeyExW(HKEY_CURRENT_USER,
|
||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\SysTray",
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_READ,
|
||||
NULL,
|
||||
&hKey,
|
||||
NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
dwSize = sizeof(DWORD);
|
||||
RegQueryValueExW(hKey,
|
||||
L"Services",
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)&this->dwServicesEnabled,
|
||||
&dwSize);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
VOID CSysTray::EnableService(DWORD dwServiceFlag, BOOL bEnable)
|
||||
{
|
||||
HKEY hKey;
|
||||
|
||||
if (bEnable)
|
||||
this->dwServicesEnabled |= dwServiceFlag;
|
||||
else
|
||||
this->dwServicesEnabled &= ~dwServiceFlag;
|
||||
|
||||
if (RegCreateKeyExW(HKEY_CURRENT_USER,
|
||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\SysTray",
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&hKey,
|
||||
NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
RegSetValueExW(hKey,
|
||||
L"Services",
|
||||
0,
|
||||
REG_DWORD,
|
||||
(LPBYTE)&this->dwServicesEnabled,
|
||||
sizeof(DWORD));
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CSysTray::IsServiceEnabled(DWORD dwServiceFlag)
|
||||
{
|
||||
return (this->dwServicesEnabled & dwServiceFlag);
|
||||
}
|
||||
|
||||
HRESULT CSysTray::InitNetShell()
|
||||
{
|
||||
HRESULT hr = CoCreateInstance(CLSID_ConnectionTray, 0, 1u, IID_PPV_ARG(IOleCommandTarget, &pctNetShell));
|
||||
|
@ -49,9 +114,12 @@ HRESULT CSysTray::InitIcons()
|
|||
TRACE("Initializing Notification icons...\n");
|
||||
for (int i = 0; i < g_NumIcons; i++)
|
||||
{
|
||||
HRESULT hr = g_IconHandlers[i].pfnInit(this);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
if (this->dwServicesEnabled & g_IconHandlers[i].dwServiceFlag)
|
||||
{
|
||||
HRESULT hr = g_IconHandlers[i].pfnInit(this);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return InitNetShell();
|
||||
|
@ -62,9 +130,12 @@ HRESULT CSysTray::ShutdownIcons()
|
|||
TRACE("Shutting down Notification icons...\n");
|
||||
for (int i = 0; i < g_NumIcons; i++)
|
||||
{
|
||||
HRESULT hr = g_IconHandlers[i].pfnShutdown(this);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
if (this->dwServicesEnabled & g_IconHandlers[i].dwServiceFlag)
|
||||
{
|
||||
HRESULT hr = g_IconHandlers[i].pfnShutdown(this);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return ShutdownNetShell();
|
||||
|
@ -75,9 +146,12 @@ HRESULT CSysTray::UpdateIcons()
|
|||
TRACE("Updating Notification icons...\n");
|
||||
for (int i = 0; i < g_NumIcons; i++)
|
||||
{
|
||||
HRESULT hr = g_IconHandlers[i].pfnUpdate(this);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
if (this->dwServicesEnabled & g_IconHandlers[i].dwServiceFlag)
|
||||
{
|
||||
HRESULT hr = g_IconHandlers[i].pfnUpdate(this);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
@ -236,6 +310,7 @@ BOOL CSysTray::ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
return FALSE;
|
||||
|
||||
case WM_CREATE:
|
||||
GetServicesEnabled();
|
||||
InitIcons();
|
||||
SetTimer(1, 2000, NULL);
|
||||
return TRUE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue