ReactOS 0.4.15-dev-8116-gf69e256
powercfg.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Power Configuration Applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/powercfg/powercfg.c
5 * PURPOSE: initialization of applet
6 * PROGRAMMERS: Alexander Wurzinger (Lohnegrim at gmx dot net)
7 * Johannes Anderwald (johannes.anderwald@reactos.org)
8 * Martin Rottensteiner
9 * Dmitry Chapyshev (lentind@yandex.ru)
10 */
11
12#include "powercfg.h"
13
14#include <winreg.h>
15#include <regstr.h>
16
17#define NUM_APPLETS (1)
18
20
21
25
26/* Applets */
28{
30};
31
32static BOOL CALLBACK
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}
44
45static BOOL
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}
69
70static int CALLBACK
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}
87
88/* First Applet */
89static LONG APIENTRY
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}
150
151/* Control Panel Callback */
154 UINT uMsg,
155 LPARAM lParam1,
156 LPARAM lParam2)
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}
197
198
203{
205
206 switch (dwReason)
207 {
210 hApplet = hinstDLL;
211 break;
212 }
213
214 return TRUE;
215}
unsigned char BOOLEAN
INT_PTR CALLBACK AlarmsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: alarms.c:167
DWORD dwReason
Definition: misc.cpp:154
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 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 DLGPROC
Definition: maze.c:62
WORD idDlg
Definition: desk.c:121
DLGPROC DlgProc
Definition: desk.c:122
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_CPLICON_1
Definition: resource.h:4
#define IDS_CPLDESCRIPTION_1
Definition: resource.h:8
#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
#define APIENTRY
Definition: api.h:79
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define CALLBACK
Definition: compat.h:35
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
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
INT_PTR CALLBACK HibernateDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hibernate.c:90
#define TEXT(s)
Definition: k32.h:26
static IN DWORD IN LPVOID lpvReserved
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
#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
#define NUM_APPLETS
Definition: powercfg.c:17
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
TCHAR langSel[255]
Definition: powercfg.c:24
BOOLEAN WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
Definition: powercfg.c:200
GLOBAL_POWER_POLICY gGPP
Definition: powercfg.c:23
APPLET Applets[NUM_APPLETS]
Definition: powercfg.c:27
static LONG APIENTRY Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: powercfg.c:90
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 CreatePropertySheetPage
Definition: prsht.h:399
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSP_DEFAULT
Definition: prsht.h:22
#define PropertySheet
Definition: prsht.h:400
#define PSH_USEICONID
Definition: prsht.h:42
#define PSCB_INITIALIZED
Definition: prsht.h:75
#define PROPSHEETPAGE
Definition: prsht.h:389
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2190
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:2013
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:2043
Definition: hotplug.h:34
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
BOOLEAN SystemBatteriesPresent
Definition: ntpoapi.h:374
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
#define ICON_BIG
Definition: tnclass.cpp:51
int ret
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define MAKEINTRESOURCE
Definition: winuser.h:591
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2106
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char TCHAR
Definition: xmlstorage.h:189