Author: ekohl
Date: Thu Mar 23 20:00:54 2017
New Revision: 74226
URL:
http://svn.reactos.org/svn/reactos?rev=74226&view=rev
Log:
[POWERCFG]
Show and hide the power systray icon.
Modified:
trunk/reactos/dll/cpl/powercfg/advanced.c
Modified: trunk/reactos/dll/cpl/powercfg/advanced.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/powercfg/advanced.…
==============================================================================
--- trunk/reactos/dll/cpl/powercfg/advanced.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/powercfg/advanced.c [iso-8859-1] Thu Mar 23 20:00:54 2017
@@ -17,6 +17,32 @@
static POWER_ACTION g_PowerButton[5];
static POWER_ACTION g_SleepButton[5];
+
+static
+VOID
+SetSystrayPowerIconState(BOOL bEnabled)
+{
+ HWND hwndTaskBar;
+
+ hwndTaskBar = FindWindowW(L"SystemTray_Main", NULL);
+ if (hwndTaskBar == NULL)
+ return;
+
+ SendMessageW(hwndTaskBar, WM_USER + 220, 1, bEnabled);
+}
+
+static
+BOOL
+GetSystrayPowerIconState(VOID)
+{
+ HWND hwndTaskBar;
+
+ hwndTaskBar = FindWindowW(L"SystemTray_Main", NULL);
+ if (hwndTaskBar == NULL)
+ return FALSE;
+
+ return (BOOL)SendMessageW(hwndTaskBar, WM_USER + 221, 1, 0);
+}
static VOID
AddItem(HWND hDlgCtrl, INT ResourceId, LPARAM lParam, POWER_ACTION * lpAction)
@@ -278,6 +304,11 @@
SYSTEM_POWER_CAPABILITIES spc;
+ if (GetSystrayPowerIconState())
+ gGPP.user.GlobalFlags |= EnableSysTrayBatteryMeter;
+ else
+ gGPP.user.GlobalFlags &= ~EnableSysTrayBatteryMeter;
+
CheckDlgButton(hAdv,
IDC_SYSTRAYBATTERYMETER,
gGPP.user.GlobalFlags & EnableSysTrayBatteryMeter ? BST_CHECKED :
BST_UNCHECKED);
@@ -351,7 +382,7 @@
ShowWindow(hList2, FALSE);
}
- hList3=GetDlgItem(hAdv, IDC_SLEEPBUTTON);
+ hList3 = GetDlgItem(hAdv, IDC_SLEEPBUTTON);
SendMessage(hList3, CB_RESETCONTENT, 0, 0);
memset(g_SleepButton, 0x0, sizeof(g_SleepButton));
@@ -469,6 +500,8 @@
{
MessageBox(hwndDlg, L"WriteGlobalPwrPolicy failed", NULL, MB_OK);
}
+
+ SetSystrayPowerIconState(!bSystrayBatteryMeter);
Adv_InitDialog();
}