ReactOS 0.4.15-dev-5666-gc548b97
powercfg.c File Reference
#include "powercfg.h"
#include <winreg.h>
#include <regstr.h>
Include dependency graph for powercfg.c:

Go to the source code of this file.

Macros

#define NUM_APPLETS   (1)
 

Functions

static LONG APIENTRY Applet1 (HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
 
static BOOL CALLBACK PropSheetAddPage (HPROPSHEETPAGE hpage, LPARAM lParam)
 
static BOOL InitPropSheetPage (PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
 
static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam)
 
LONG CALLBACK CPlApplet (HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
 
BOOLEAN WINAPI DllMain (HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
 

Variables

HINSTANCE hApplet = 0
 
GLOBAL_POWER_POLICY gGPP
 
TCHAR langSel [255]
 
APPLET Applets [NUM_APPLETS]
 

Macro Definition Documentation

◆ NUM_APPLETS

#define NUM_APPLETS   (1)

Definition at line 17 of file powercfg.c.

Function Documentation

◆ Applet1()

static LONG APIENTRY Applet1 ( HWND  hwnd,
UINT  uMsg,
LPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 90 of file powercfg.c.

91{
94 HPSXA hpsxa = NULL;
96 LONG ret;
97
101
102 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
103 psh.dwSize = sizeof(PROPSHEETHEADER);
105 psh.hwndParent = hwnd;
106 psh.hInstance = hApplet;
107 psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON_1);
108 psh.pszCaption = MAKEINTRESOURCEW(IDS_CPLNAME_1);
109 psh.nPages = 0;
110 psh.nStartPage = 0;
111 psh.phpage = hpsp;
112 psh.pfnCallback = PropSheetProc;
113
114 if (!GetPwrCapabilities(&spc))
115 {
116 return GetLastError();
117 }
118
120 {
123
124 /* FIXME: Add battery page */
125 }
126 else
127 {
129 }
131 if (spc.SystemS4)
132 {
134 }
135
136 /* FIXME: Add UPS page */
137
138 /* Load additional pages provided by shell extensions */
140 if (hpsxa != NULL)
142
143 ret = (LONG)(PropertySheet(&psh) != -1);
144
145 if (hpsxa != NULL)
147
148 return ret;
149}
INT_PTR CALLBACK AlarmsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: alarms.c:167
static INT_PTR CALLBACK AdvancedDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: charmap.c:480
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define IDC_CPLICON_1
Definition: resource.h:4
#define IDS_CPLNAME_1
Definition: resource.h:6
#define IDD_POWERSCHEMESPAGE_ACDC
Definition: resource.h:14
#define IDD_PROPPAGEHIBERNATE
Definition: resource.h:19
#define IDD_POWERSCHEMESPAGE_AC
Definition: resource.h:15
#define IDD_PROPPAGEADVANCED
Definition: resource.h:18
#define IDD_PROPPAGEALARMS
Definition: resource.h:16
INT_PTR CALLBACK HibernateDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hibernate.c:90
#define TEXT(s)
Definition: k32.h:26
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
long LONG
Definition: pedump.c:60
static BOOL InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
Definition: powercfg.c:46
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: powercfg.c:33
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: powercfg.c:71
HINSTANCE hApplet
Definition: powercfg.c:22
INT_PTR CALLBACK PowerSchemesDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: powershemes.c:825
#define MAX_POWER_PAGES
Definition: powercfg.h:35
BOOLEAN WINAPI GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)
Definition: powrprof.c:358
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PSH_PROPTITLE
Definition: prsht.h:40
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PropertySheet
Definition: prsht.h:400
#define PSH_USEICONID
Definition: prsht.h:42
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2150
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1973
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:2003
BOOLEAN SystemBatteriesPresent
Definition: ntpoapi.h:374
int ret
#define ZeroMemory
Definition: winbase.h:1670
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ CPlApplet()

LONG CALLBACK CPlApplet ( HWND  hwndCPl,
UINT  uMsg,
LPARAM  lParam1,
LPARAM  lParam2 
)

Definition at line 153 of file powercfg.c.

157{
158 UINT i = (UINT)lParam1;
159
160 switch (uMsg)
161 {
162 case CPL_INIT:
163 {
164 return TRUE;
165 }
166
167 case CPL_GETCOUNT:
168 {
169 return NUM_APPLETS;
170 }
171
172 case CPL_INQUIRE:
173 if (i < NUM_APPLETS)
174 {
175 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
176 CPlInfo->lData = 0;
177 CPlInfo->idIcon = Applets[i].idIcon;
178 CPlInfo->idName = Applets[i].idName;
179 CPlInfo->idInfo = Applets[i].idDescription;
180 }
181 else
182 {
183 return TRUE;
184 }
185 break;
186
187 case CPL_DBLCLK:
188 if (i < NUM_APPLETS)
189 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
190 else
191 return TRUE;
192 break;
193 }
194
195 return FALSE;
196}
#define CPL_INQUIRE
Definition: cpl.h:14
#define CPL_DBLCLK
Definition: cpl.h:16
#define CPL_INIT
Definition: cpl.h:12
#define CPL_GETCOUNT
Definition: cpl.h:13
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
#define NUM_APPLETS
Definition: powercfg.c:17
APPLET Applets[NUM_APPLETS]
Definition: powercfg.c:27
int idDescription
Definition: hotplug.h:37
int idName
Definition: hotplug.h:36
int idIcon
Definition: hotplug.h:35
APPLET_PROC AppletProc
Definition: hotplug.h:38
Definition: cpl.h:24
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25

◆ DllMain()

BOOLEAN WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  dwReason,
LPVOID  lpvReserved 
)

Definition at line 200 of file powercfg.c.

203{
205
206 switch (dwReason)
207 {
210 hApplet = hinstDLL;
211 break;
212 }
213
214 return TRUE;
215}
DWORD dwReason
Definition: misc.cpp:154
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static IN DWORD IN LPVOID lpvReserved

◆ InitPropSheetPage()

static BOOL InitPropSheetPage ( PROPSHEETHEADER ppsh,
WORD  idDlg,
DLGPROC  DlgProc 
)
static

Definition at line 46 of file powercfg.c.

47{
48 HPROPSHEETPAGE hPage;
49 PROPSHEETPAGE psp;
50
51 if (ppsh->nPages < MAX_POWER_PAGES)
52 {
53 ZeroMemory(&psp, sizeof(psp));
54 psp.dwSize = sizeof(psp);
55 psp.dwFlags = PSP_DEFAULT;
56 psp.hInstance = hApplet;
57 psp.pszTemplate = MAKEINTRESOURCE(idDlg);
58 psp.pfnDlgProc = DlgProc;
59
60 hPage = CreatePropertySheetPage(&psp);
61 if (hPage != NULL)
62 {
63 return PropSheetAddPage(hPage, (LPARAM)ppsh);
64 }
65 }
66
67 return FALSE;
68}
WORD idDlg
Definition: desk.c:110
DLGPROC DlgProc
Definition: desk.c:111
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSP_DEFAULT
Definition: prsht.h:22
#define PROPSHEETPAGE
Definition: prsht.h:389
#define MAKEINTRESOURCE
Definition: winuser.h:591

Referenced by Applet1().

◆ PropSheetAddPage()

static BOOL CALLBACK PropSheetAddPage ( HPROPSHEETPAGE  hpage,
LPARAM  lParam 
)
static

Definition at line 33 of file powercfg.c.

34{
36 if (ppsh != NULL && ppsh->nPages < MAX_POWER_PAGES)
37 {
38 ppsh->phpage[ppsh->nPages++] = hpage;
39 return TRUE;
40 }
41
42 return FALSE;
43}

Referenced by Applet1(), and InitPropSheetPage().

◆ PropSheetProc()

static int CALLBACK PropSheetProc ( HWND  hwndDlg,
UINT  uMsg,
LPARAM  lParam 
)
static

Definition at line 71 of file powercfg.c.

72{
73 // NOTE: This callback is needed to set large icon correctly.
75
76 switch (uMsg)
77 {
79 {
81 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
82 break;
83 }
84 }
85 return 0;
86}
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define PSCB_INITIALIZED
Definition: prsht.h:75
#define ICON_BIG
Definition: tnclass.cpp:51
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by Applet1().

Variable Documentation

◆ Applets

APPLET Applets[NUM_APPLETS]
Initial value:
=
{
}
#define IDS_CPLDESCRIPTION_1
Definition: resource.h:8
static LONG APIENTRY Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: powercfg.c:90

Definition at line 27 of file powercfg.c.

Referenced by CPlApplet().

◆ gGPP

◆ hApplet

HINSTANCE hApplet = 0

Definition at line 22 of file powercfg.c.

Referenced by Applet1(), DllMain(), InitPropSheetPage(), and PropSheetProc().

◆ langSel

TCHAR langSel[255]

Definition at line 24 of file powercfg.c.

Referenced by CreateLanguagesList(), and InitLanguagesList().