Author: ekohl
Date: Sat Mar 25 13:35:41 2017
New Revision: 74228
URL:
http://svn.reactos.org/svn/reactos?rev=74228&view=rev
Log:
[STOBJECT]
Implement the power schemes popup menu.
Modified:
trunk/reactos/dll/shellext/stobject/CMakeLists.txt
trunk/reactos/dll/shellext/stobject/power.cpp
Modified: trunk/reactos/dll/shellext/stobject/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/stobject/CMak…
==============================================================================
--- trunk/reactos/dll/shellext/stobject/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/stobject/CMakeLists.txt [iso-8859-1] Sat Mar 25 13:35:41
2017
@@ -33,6 +33,7 @@
winmm
ole32
oleaut32
+ powrprof
shlwapi
shell32
comctl32
Modified: trunk/reactos/dll/shellext/stobject/power.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/stobject/powe…
==============================================================================
--- trunk/reactos/dll/shellext/stobject/power.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/shellext/stobject/power.cpp [iso-8859-1] Sat Mar 25 13:35:41 2017
@@ -8,6 +8,7 @@
*/
#include "precomp.h"
+#include "powrprof.h"
#include <mmsystem.h>
#include <mmddk.h>
@@ -16,6 +17,13 @@
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
WINE_DEFAULT_DEBUG_CHANNEL(stobject);
+
+typedef struct _PWRSCHEMECONTEXT
+{
+ HMENU hPopup;
+ UINT uiFirst;
+ UINT uiLast;
+} PWRSCHEMECONTEXT, *PPWRSCHEMECONTEXT;
//static HICON g_hIconBattery = NULL;
static HICON g_hIconAC = NULL;
@@ -120,6 +128,68 @@
}
}
+static
+BOOLEAN
+CALLBACK
+PowerSchemesEnumProc(
+ UINT uiIndex,
+ DWORD dwName,
+ LPWSTR sName,
+ DWORD dwDesc,
+ LPWSTR sDesc,
+ PPOWER_POLICY pp,
+ LPARAM lParam)
+{
+ PPWRSCHEMECONTEXT PowerSchemeContext = (PPWRSCHEMECONTEXT)lParam;
+
+ if (AppendMenuW(PowerSchemeContext->hPopup, MF_STRING, uiIndex + 1, sName))
+ {
+ if (PowerSchemeContext->uiFirst == 0)
+ PowerSchemeContext->uiFirst = uiIndex + 1;
+
+ PowerSchemeContext->uiLast = uiIndex + 1;
+ }
+
+ return TRUE;
+}
+
+static
+VOID
+ShowPowerSchemesPopupMenu(
+ CSysTray *pSysTray)
+{
+ PWRSCHEMECONTEXT PowerSchemeContext = {NULL, 0, 0};
+ UINT uiActiveScheme;
+ DWORD id, msgPos;
+
+ PowerSchemeContext.hPopup = CreatePopupMenu();
+ EnumPwrSchemes(PowerSchemesEnumProc, (LPARAM)&PowerSchemeContext);
+
+ if (GetActivePwrScheme(&uiActiveScheme))
+ {
+ CheckMenuRadioItem(PowerSchemeContext.hPopup,
+ PowerSchemeContext.uiFirst,
+ PowerSchemeContext.uiLast,
+ uiActiveScheme + 1,
+ MF_BYCOMMAND);
+ }
+
+ msgPos = GetMessagePos();
+
+ SetForegroundWindow(pSysTray->GetHWnd());
+ id = TrackPopupMenuEx(PowerSchemeContext.hPopup,
+ TPM_RETURNCMD | TPM_NONOTIFY | TPM_RIGHTALIGN |
TPM_BOTTOMALIGN,
+ GET_X_LPARAM(msgPos),
+ GET_Y_LPARAM(msgPos),
+ pSysTray->GetHWnd(),
+ NULL);
+
+ DestroyMenu(PowerSchemeContext.hPopup);
+
+ if (id != 0)
+ SetActivePwrScheme(id - 1, NULL, NULL);
+}
+
HRESULT STDMETHODCALLTYPE Power_Message(_In_ CSysTray * pSysTray, UINT uMsg, WPARAM
wParam, LPARAM lParam, LRESULT &lResult)
{
TRACE("Power_Message uMsg=%d, wParam=%x, lParam=%x\n", uMsg, wParam,
lParam);
@@ -155,7 +225,7 @@
break;
case WM_LBUTTONUP:
- TRACE("TODO: display power options!\n");
+ ShowPowerSchemesPopupMenu(pSysTray);
break;
case WM_LBUTTONDBLCLK:
@@ -167,6 +237,7 @@
case WM_RBUTTONUP:
_ShowContextMenu(pSysTray);
+ break;
case WM_RBUTTONDBLCLK:
break;