Skip to content

Commit

Permalink
[POWERCFG]
Browse files Browse the repository at this point in the history
Show and hide the power systray icon.

svn path=/trunk/; revision=74226
  • Loading branch information
EricKohl committed Mar 23, 2017
1 parent a926541 commit 3bce3e3
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion reactos/dll/cpl/powercfg/advanced.c
Expand Up @@ -18,6 +18,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)
{
Expand Down Expand Up @@ -278,6 +304,11 @@ Adv_InitDialog(VOID)

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);
Expand Down Expand Up @@ -351,7 +382,7 @@ Adv_InitDialog(VOID)
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));

Expand Down Expand Up @@ -470,6 +501,8 @@ Adv_SaveData(HWND hwndDlg)
MessageBox(hwndDlg, L"WriteGlobalPwrPolicy failed", NULL, MB_OK);
}

SetSystrayPowerIconState(!bSystrayBatteryMeter);

Adv_InitDialog();
}

Expand Down

0 comments on commit 3bce3e3

Please sign in to comment.