diff --git a/dll/shellext/stobject/power.cpp b/dll/shellext/stobject/power.cpp index ecae456b66ec2..7f714cf62532f 100644 --- a/dll/shellext/stobject/power.cpp +++ b/dll/shellext/stobject/power.cpp @@ -29,6 +29,8 @@ typedef struct _PWRSCHEMECONTEXT CString g_strTooltip; static HICON g_hIconBattery = NULL; +#define HOUR_IN_SECS 3600 +#define MIN_IN_SECS 60 /*++ * @name Quantize @@ -78,6 +80,7 @@ static HICON DynamicLoadIcon(HINSTANCE hinst) { SYSTEM_POWER_STATUS PowerStatus; HICON hBatIcon; + UINT uiHour, uiMin; UINT index = -1; if (!GetSystemPowerStatus(&PowerStatus) || @@ -107,7 +110,25 @@ static HICON DynamicLoadIcon(HINSTANCE hinst) { index = Quantize(PowerStatus.BatteryLifePercent); hBatIcon = LoadIcon(hinst, MAKEINTRESOURCE(br_icons[index])); - g_strTooltip.Format(IDS_PWR_PERCENT_REMAINING, PowerStatus.BatteryLifePercent); + + if (PowerStatus.BatteryLifeTime != BATTERY_UNKNOWN_TIME) + { + uiHour = PowerStatus.BatteryLifeTime / HOUR_IN_SECS; + uiMin = (PowerStatus.BatteryLifeTime % HOUR_IN_SECS) / MIN_IN_SECS; + + if (uiHour != 0) + { + g_strTooltip.Format(IDS_PWR_HOURS_REMAINING, uiHour, uiMin, PowerStatus.BatteryLifePercent); + } + else + { + g_strTooltip.Format(IDS_PWR_MINUTES_REMAINING, uiMin, PowerStatus.BatteryLifePercent); + } + } + else + { + g_strTooltip.Format(IDS_PWR_PERCENT_REMAINING, PowerStatus.BatteryLifePercent); + } } else {