ReactOS  0.4.14-dev-604-gcfdd483
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 {
93  PROPSHEETHEADER psh;
94  HPSXA hpsxa = NULL;
95  TCHAR Caption[1024];
97  LONG ret;
98 
102 
103  memset(Caption, 0x0, sizeof(Caption));
104  LoadString(hApplet, IDS_CPLNAME_1, Caption, sizeof(Caption) / sizeof(TCHAR));
105 
106  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
107  psh.dwSize = sizeof(PROPSHEETHEADER);
108  psh.dwFlags = PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
109  psh.hwndParent = hwnd;
110  psh.hInstance = hApplet;
111  psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON_1);
112  psh.pszCaption = Caption;
113  psh.nPages = 0;
114  psh.nStartPage = 0;
115  psh.phpage = hpsp;
116  psh.pfnCallback = PropSheetProc;
117 
118  if (!GetPwrCapabilities(&spc))
119  {
120  return GetLastError();
121  }
122 
123  if (spc.SystemBatteriesPresent)
124  {
127  }
128  else
129  {
131  }
133  if (spc.SystemS4)
134  {
136  }
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 }
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:1755
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLint x0
Definition: linetemp.h:95
#define IDD_POWERSCHEMESPAGE_AC
Definition: resource.h:15
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1577
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
BOOLEAN SystemBatteriesPresent
Definition: ntpoapi.h:374
BOOLEAN WINAPI GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)
Definition: powrprof.c:358
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
#define PSH_USECALLBACK
Definition: prsht.h:48
WPARAM wParam
Definition: combotst.c:138
#define IDD_PROPPAGEALARMS
Definition: resource.h:16
INT_PTR CALLBACK AdvancedDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: advanced.c:225
#define PSH_USEICONID
Definition: prsht.h:42
long LONG
Definition: pedump.c:60
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
smooth NULL
Definition: ftsmooth.c:416
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: powercfg.c:33
#define PROPSHEETHEADER
Definition: prsht.h:374
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_CPLNAME_1
Definition: resource.h:6
char TCHAR
Definition: xmlstorage.h:189
INT_PTR CALLBACK PowerSchemesDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: powershemes.c:808
#define PSH_PROPTITLE
Definition: prsht.h:40
#define IDD_POWERSCHEMESPAGE_ACDC
Definition: resource.h:14
int ret
static BOOL InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
Definition: powercfg.c:46
INT_PTR CALLBACK HibernateDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hibernate.c:83
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: powercfg.c:71
#define TEXT(s)
Definition: k32.h:26
INT_PTR CALLBACK AlarmsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: alarms.c:167
HINSTANCE hApplet
Definition: powercfg.c:22
#define IDD_PROPPAGEHIBERNATE
Definition: resource.h:19
#define PropertySheet
Definition: prsht.h:382
#define IDC_CPLICON_1
Definition: resource.h:4
#define MAX_POWER_PAGES
Definition: powercfg.h:36
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:1607
#define IDD_PROPPAGEADVANCED
Definition: resource.h:18
#define memset(x, y, z)
Definition: compat.h:39
LPARAM lParam
Definition: combotst.c:139
#define LoadString
Definition: winuser.h:5794
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ CPlApplet()

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

Definition at line 153 of file powercfg.c.

157 {
158  int i = (int)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  {
174  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
175  CPlInfo->lData = 0;
176  CPlInfo->idIcon = Applets[i].idIcon;
177  CPlInfo->idName = Applets[i].idName;
178  CPlInfo->idInfo = Applets[i].idDescription;
179  break;
180  }
181 
182  case CPL_DBLCLK:
183  {
184  Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
185  break;
186  }
187  }
188 
189  return FALSE;
190 }
#define TRUE
Definition: types.h:120
Definition: cpl.h:24
int idName
Definition: hotplug.h:27
int idIcon
Definition: hotplug.h:26
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:28
#define CPL_DBLCLK
Definition: cpl.h:16
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
APPLET_PROC AppletProc
Definition: hotplug.h:29
#define CPL_INIT
Definition: cpl.h:12
#define CPL_INQUIRE
Definition: cpl.h:14
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
APPLET Applets[NUM_APPLETS]
Definition: powercfg.c:27
#define NUM_APPLETS
Definition: powercfg.c:17
#define CPL_GETCOUNT
Definition: cpl.h:13
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ DllMain()

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

Definition at line 194 of file powercfg.c.

197 {
199 
200  switch (dwReason)
201  {
202  case DLL_PROCESS_ATTACH:
203  DisableThreadLibraryCalls(hinstDLL);
204  hApplet = hinstDLL;
205  break;
206  }
207 
208  return TRUE;
209 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static IN DWORD IN LPVOID lpvReserved
DWORD dwReason
Definition: misc.cpp:154
HINSTANCE hApplet
Definition: powercfg.c:22

◆ 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:109
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ZeroMemory
Definition: winbase.h:1642
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
smooth NULL
Definition: ftsmooth.c:416
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: powercfg.c:33
LONG_PTR LPARAM
Definition: windef.h:208
#define CreatePropertySheetPage
Definition: prsht.h:381
#define PSP_DEFAULT
Definition: prsht.h:22
HINSTANCE hApplet
Definition: powercfg.c:22
#define MAX_POWER_PAGES
Definition: powercfg.h:36
DLGPROC DlgProc
Definition: desk.c:110
#define PROPSHEETPAGE
Definition: prsht.h:371

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 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:374
#define MAX_POWER_PAGES
Definition: powercfg.h:36
LPARAM lParam
Definition: combotst.c:139

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.
74  HICON hIcon;
75 
76  switch (uMsg)
77  {
78  case PSCB_INITIALIZED:
79  {
81  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
82  break;
83  }
84  }
85  return 0;
86 }
static HICON
Definition: imagelist.c:84
LONG_PTR LPARAM
Definition: windef.h:208
#define PSCB_INITIALIZED
Definition: prsht.h:75
HICON hIcon
Definition: msconfig.c:44
HINSTANCE hApplet
Definition: powercfg.c:22
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_CPLICON_1
Definition: resource.h:4
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ICON_BIG
Definition: tnclass.cpp:51

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
#define IDS_CPLNAME_1
Definition: resource.h:6
#define IDC_CPLICON_1
Definition: resource.h:4

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().