ReactOS  0.4.13-dev-242-g611e6d7
powershemes.c File Reference
#include "powercfg.h"
Include dependency graph for powershemes.c:

Go to the source code of this file.

Classes

struct  _POWER_SCHEME
 
struct  _POWER_SCHEMES_PAGE_DATA
 
struct  _SAVE_POWER_SCHEME_DATA
 

Typedefs

typedef struct _POWER_SCHEME POWER_SCHEME
 
typedef struct _POWER_SCHEMEPPOWER_SCHEME
 
typedef struct _POWER_SCHEMES_PAGE_DATA POWER_SCHEMES_PAGE_DATA
 
typedef struct _POWER_SCHEMES_PAGE_DATAPPOWER_SCHEMES_PAGE_DATA
 
typedef struct _SAVE_POWER_SCHEME_DATA SAVE_POWER_SCHEME_DATA
 
typedef struct _SAVE_POWER_SCHEME_DATAPSAVE_POWER_SCHEME_DATA
 

Functions

static PPOWER_SCHEME AddPowerScheme (PPOWER_SCHEMES_PAGE_DATA pPageData, UINT uId, DWORD dwName, LPTSTR pszName, DWORD dwDescription, LPWSTR pszDescription, PPOWER_POLICY pp)
 
static VOID DeletePowerScheme (PPOWER_SCHEME pScheme)
 
static BOOLEAN CALLBACK EnumPowerSchemeCallback (UINT uiIndex, DWORD dwName, LPTSTR pszName, DWORD dwDesc, LPWSTR pszDesc, PPOWER_POLICY pp, LPARAM lParam)
 
static VOID BuildSchemesList (PPOWER_SCHEMES_PAGE_DATA pPageData)
 
static VOID DestroySchemesList (PPOWER_SCHEMES_PAGE_DATA pPageData)
 
BOOLEAN Pos_InitData (HWND hwndDlg)
 
static VOID LoadConfig (HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData, PPOWER_SCHEME pScheme)
 
static VOID Pos_InitPage (HWND hwndDlg)
 
static VOID Pos_SaveData (HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData)
 
static BOOL DelScheme (HWND hwnd, PPOWER_SCHEMES_PAGE_DATA pPageData)
 
static BOOL SavePowerScheme (HWND hwndDlg, PSAVE_POWER_SCHEME_DATA pSaveSchemeData)
 
INT_PTR CALLBACK SaveSchemeDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID SaveScheme (HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData)
 
static BOOL CreateEnergyList (HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData)
 
INT_PTR CALLBACK PowerSchemesDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

UINT Sec []
 

Typedef Documentation

◆ POWER_SCHEME

◆ POWER_SCHEMES_PAGE_DATA

◆ PPOWER_SCHEME

◆ PPOWER_SCHEMES_PAGE_DATA

◆ PSAVE_POWER_SCHEME_DATA

◆ SAVE_POWER_SCHEME_DATA

Function Documentation

◆ AddPowerScheme()

static PPOWER_SCHEME AddPowerScheme ( PPOWER_SCHEMES_PAGE_DATA  pPageData,
UINT  uId,
DWORD  dwName,
LPTSTR  pszName,
DWORD  dwDescription,
LPWSTR  pszDescription,
PPOWER_POLICY  pp 
)
static

Definition at line 64 of file powershemes.c.

72 {
73  PPOWER_SCHEME pScheme;
74  BOOL bResult = FALSE;
75 
76  pScheme = HeapAlloc(GetProcessHeap(),
78  sizeof(POWER_SCHEME));
79  if (pScheme == NULL)
80  return NULL;
81 
82  pScheme->uId = uId;
83  CopyMemory(&pScheme->PowerPolicy, pp, sizeof(POWER_POLICY));
84 
85  if (dwName != 0)
86  {
87  pScheme->pszName = HeapAlloc(GetProcessHeap(),
89  dwName);
90  if (pScheme->pszName == NULL)
91  goto done;
92 
93  _tcscpy(pScheme->pszName, pszName);
94  }
95 
96  if (dwDescription != 0)
97  {
100  dwDescription);
101  if (pScheme->pszDescription == NULL)
102  goto done;
103 
104  _tcscpy(pScheme->pszDescription, pszDescription);
105  }
106 
107  InsertTailList(&pPageData->PowerSchemesList, &pScheme->ListEntry);
108  bResult = TRUE;
109 
110 done:
111  if (bResult == FALSE)
112  {
113  if (pScheme->pszName)
114  HeapFree(GetProcessHeap(), 0, pScheme->pszName);
115 
116  if (pScheme->pszDescription)
117  HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
118 
119  HeapFree(GetProcessHeap(), 0, pScheme);
120  pScheme = NULL;
121  }
122 
123  return pScheme;
124 }
#define TRUE
Definition: types.h:120
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define InsertTailList(ListHead, Entry)
LIST_ENTRY ListEntry
Definition: powershemes.c:17
LPTSTR pszName
Definition: powershemes.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
#define pp
Definition: hlsl.yy.c:978
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CopyMemory
Definition: winbase.h:1633
POWER_POLICY PowerPolicy
Definition: powershemes.c:21
LPTSTR pszDescription
Definition: powershemes.c:20
LIST_ENTRY PowerSchemesList
Definition: powershemes.c:27
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by EnumPowerSchemeCallback(), and SavePowerScheme().

◆ BuildSchemesList()

static VOID BuildSchemesList ( PPOWER_SCHEMES_PAGE_DATA  pPageData)
static

Definition at line 172 of file powershemes.c.

174 {
176 
178 }
static BOOLEAN CALLBACK EnumPowerSchemeCallback(UINT uiIndex, DWORD dwName, LPTSTR pszName, DWORD dwDesc, LPWSTR pszDesc, PPOWER_POLICY pp, LPARAM lParam)
Definition: powershemes.c:147
LONG_PTR LPARAM
Definition: windef.h:208
BOOLEAN WINAPI EnumPwrSchemes(PWRSCHEMESENUMPROC lpfnPwrSchemesEnumProc, LPARAM lParam)
Definition: powrprof.c:219
LIST_ENTRY PowerSchemesList
Definition: powershemes.c:27
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944

Referenced by PowerSchemesDlgProc().

◆ CreateEnergyList()

static BOOL CreateEnergyList ( HWND  hwndDlg,
PPOWER_SCHEMES_PAGE_DATA  pPageData 
)
static

Definition at line 721 of file powershemes.c.

724 {
725  PLIST_ENTRY ListEntry;
726  PPOWER_SCHEME pScheme;
727  INT index;
730  HWND hwndList;
731  UINT aps = 0;
732 
733  hwndList = GetDlgItem(hwndDlg, IDC_ENERGYLIST);
734 
735  if (!GetActivePwrScheme(&aps))
736  return FALSE;
737 
738  if (!ReadGlobalPwrPolicy(&gGPP))
739  return FALSE;
740 
741  if (!ReadPwrScheme(aps, &pp))
742  return FALSE;
743 
744  if (!ValidatePowerPolicies(&gGPP, 0))
745  return FALSE;
746 
747 /*
748  if (!SetActivePwrScheme(aps, &gGPP, &pp))
749  return FALSE;
750 */
751 
752  if (!GetPwrCapabilities(&spc))
753  return FALSE;
754 
755  if (CanUserWritePwrScheme())
756  {
757  // TODO:
758  // Enable write / delete powerscheme button
759  }
760 
761  Pos_InitPage(hwndDlg);
762 
763  if (!GetActivePwrScheme(&aps))
764  return FALSE;
765 
766  ListEntry = pPageData->PowerSchemesList.Flink;
767  while (ListEntry != &pPageData->PowerSchemesList)
768  {
769  pScheme = CONTAINING_RECORD(ListEntry, POWER_SCHEME, ListEntry);
770 
771  index = (int)SendMessage(hwndList,
772  CB_ADDSTRING,
773  0,
774  (LPARAM)pScheme->pszName);
775  if (index == CB_ERR)
776  break;
777 
778  SendMessage(hwndList,
780  index,
781  (LPARAM)pScheme);
782 
783  if (aps == pScheme->uId)
784  {
785  SendMessage(hwndList,
787  TRUE,
788  (LPARAM)pScheme->pszName);
789 
790  pPageData->pActivePowerScheme = pScheme;
791  LoadConfig(hwndDlg, pPageData, pScheme);
792  }
793 
794  ListEntry = ListEntry->Flink;
795  }
796 
797  if (SendMessage(hwndList, CB_GETCOUNT, 0, 0) > 0)
798  {
800  }
801 
802  return TRUE;
803 }
#define CB_SETITEMDATA
Definition: winuser.h:1927
#define TRUE
Definition: types.h:120
BOOLEAN WINAPI GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)
Definition: powrprof.c:358
BOOLEAN WINAPI ReadPwrScheme(UINT uiID, PPOWER_POLICY pPowerPolicy)
Definition: powrprof.c:610
#define IDC_SAVEAS_BTN
Definition: resource.h:66
int32_t INT
Definition: typedefs.h:56
LPTSTR pszName
Definition: powershemes.c:19
#define IDC_ENERGYLIST
Definition: resource.h:58
#define pp
Definition: hlsl.yy.c:978
#define CB_ADDSTRING
Definition: winuser.h:1897
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define CB_ERR
Definition: winuser.h:2389
GLOBAL_POWER_POLICY gGPP
Definition: powercfg.c:23
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOLEAN WINAPI GetActivePwrScheme(PUINT puiID)
Definition: powrprof.c:285
static VOID LoadConfig(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData, PPOWER_SCHEME pScheme)
Definition: powershemes.c:237
#define index(s, c)
Definition: various.h:29
#define CB_SELECTSTRING
Definition: winuser.h:1921
BOOLEAN WINAPI ValidatePowerPolicies(PGLOBAL_POWER_POLICY pGPP, PPOWER_POLICY pPP)
Definition: powrprof.c:851
Definition: typedefs.h:117
static VOID Pos_InitPage(HWND hwndDlg)
Definition: powershemes.c:334
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LIST_ENTRY PowerSchemesList
Definition: powershemes.c:27
BOOLEAN WINAPI ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
Definition: powrprof.c:521
BOOLEAN WINAPI CanUserWritePwrScheme(VOID)
Definition: powrprof.c:79
unsigned int UINT
Definition: ndis.h:50
#define SendMessage
Definition: winuser.h:5709
#define CB_GETCOUNT
Definition: winuser.h:1903
PPOWER_SCHEME pActivePowerScheme
Definition: powershemes.c:28
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by PowerSchemesDlgProc().

◆ DeletePowerScheme()

static VOID DeletePowerScheme ( PPOWER_SCHEME  pScheme)
static

Definition at line 129 of file powershemes.c.

131 {
132  RemoveEntryList(&pScheme->ListEntry);
133 
134  if (pScheme->pszName)
135  HeapFree(GetProcessHeap(), 0, pScheme->pszName);
136 
137  if (pScheme->pszDescription)
138  HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
139 
140  HeapFree(GetProcessHeap(), 0, pScheme);
141 }
LIST_ENTRY ListEntry
Definition: powershemes.c:17
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
LPTSTR pszName
Definition: powershemes.c:19
#define GetProcessHeap()
Definition: compat.h:395
LPTSTR pszDescription
Definition: powershemes.c:20
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DelScheme(), DestroySchemesList(), and SavePowerScheme().

◆ DelScheme()

static BOOL DelScheme ( HWND  hwnd,
PPOWER_SCHEMES_PAGE_DATA  pPageData 
)
static

Definition at line 530 of file powershemes.c.

533 {
534  WCHAR szTitleBuffer[256];
535  WCHAR szRawBuffer[256], szCookedBuffer[512];
536  INT iCurSel;
537  HWND hList;
538  PPOWER_SCHEME pScheme;
539 
541 
542  iCurSel = SendMessage(hList, CB_GETCURSEL, 0, 0);
543  if (iCurSel == CB_ERR)
544  return FALSE;
545 
546  SendMessage(hList, CB_SETCURSEL, iCurSel, 0);
547 
548  pScheme = (PPOWER_SCHEME)SendMessage(hList, CB_GETITEMDATA, (WPARAM)iCurSel, 0);
549  if (pScheme == (PPOWER_SCHEME)CB_ERR)
550  return FALSE;
551 
552  LoadStringW(hApplet, IDS_DEL_SCHEME_TITLE, szTitleBuffer, ARRAYSIZE(szTitleBuffer));
553  LoadStringW(hApplet, IDS_DEL_SCHEME, szRawBuffer, ARRAYSIZE(szRawBuffer));
554  StringCchPrintfW(szCookedBuffer, ARRAYSIZE(szCookedBuffer), szRawBuffer, pScheme->pszName);
555 
556  if (MessageBoxW(hwnd, szCookedBuffer, szTitleBuffer, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
557  {
558  if (!DeletePwrScheme(pScheme->uId))
559  {
560  // FIXME: Show an error message box
561  return FALSE;
562  }
563 
564  iCurSel = SendMessage(hList, CB_FINDSTRING, -1, (LPARAM)pScheme->pszName);
565  if (iCurSel != CB_ERR)
566  SendMessage(hList, CB_DELETESTRING, iCurSel, 0);
567 
568  DeletePowerScheme(pScheme);
569 
570  iCurSel = SendMessage(hList, CB_FINDSTRING, -1, (LPARAM)pPageData->pActivePowerScheme->pszName);
571  if (iCurSel != CB_ERR)
572  SendMessage(hList, CB_SETCURSEL, iCurSel, 0);
573 
574  LoadConfig(hwnd, pPageData, NULL);
575  return TRUE;
576  }
577 
578  return FALSE;
579 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define IDYES
Definition: winuser.h:829
#define CB_GETITEMDATA
Definition: winuser.h:1911
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HINSTANCE hApplet
Definition: access.c:17
struct _POWER_SCHEME * PPOWER_SCHEME
UINT_PTR WPARAM
Definition: windef.h:207
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1904
LPTSTR pszName
Definition: powershemes.c:19
#define MB_YESNO
Definition: winuser.h:811
#define IDC_ENERGYLIST
Definition: resource.h:58
smooth NULL
Definition: ftsmooth.c:416
#define MB_ICONQUESTION
Definition: winuser.h:783
LONG_PTR LPARAM
Definition: windef.h:208
static VOID DeletePowerScheme(PPOWER_SCHEME pScheme)
Definition: powershemes.c:129
#define CB_ERR
Definition: winuser.h:2389
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static VOID LoadConfig(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData, PPOWER_SCHEME pScheme)
Definition: powershemes.c:237
#define IDS_DEL_SCHEME_TITLE
Definition: resource.h:49
#define CB_SETCURSEL
Definition: winuser.h:1922
HWND hList
Definition: livecd.c:10
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define IDS_DEL_SCHEME
Definition: resource.h:48
#define MB_DEFBUTTON2
Definition: winuser.h:793
#define SendMessage
Definition: winuser.h:5709
#define CB_DELETESTRING
Definition: winuser.h:1898
#define CB_FINDSTRING
Definition: winuser.h:1900
BOOLEAN WINAPI DeletePwrScheme(UINT uiIndex)
Definition: powrprof.c:99
PPOWER_SCHEME pActivePowerScheme
Definition: powershemes.c:28

Referenced by PowerSchemesDlgProc().

◆ DestroySchemesList()

static VOID DestroySchemesList ( PPOWER_SCHEMES_PAGE_DATA  pPageData)
static

Definition at line 183 of file powershemes.c.

185 {
186  PLIST_ENTRY ListEntry;
187  PPOWER_SCHEME pScheme;
188 
189  for (;;)
190  {
191  ListEntry = pPageData->PowerSchemesList.Flink;
192  if (ListEntry == &pPageData->PowerSchemesList)
193  break;
194 
195  pScheme = CONTAINING_RECORD(ListEntry, POWER_SCHEME, ListEntry);
196  DeletePowerScheme(pScheme);
197  }
198 
199  pPageData->pActivePowerScheme = NULL;
200  pPageData->pSelectedPowerScheme = NULL;
201 }
smooth NULL
Definition: ftsmooth.c:416
static VOID DeletePowerScheme(PPOWER_SCHEME pScheme)
Definition: powershemes.c:129
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
PPOWER_SCHEME pSelectedPowerScheme
Definition: powershemes.c:29
LIST_ENTRY PowerSchemesList
Definition: powershemes.c:27
PPOWER_SCHEME pActivePowerScheme
Definition: powershemes.c:28

Referenced by PowerSchemesDlgProc().

◆ EnumPowerSchemeCallback()

static BOOLEAN CALLBACK EnumPowerSchemeCallback ( UINT  uiIndex,
DWORD  dwName,
LPTSTR  pszName,
DWORD  dwDesc,
LPWSTR  pszDesc,
PPOWER_POLICY  pp,
LPARAM  lParam 
)
static

Definition at line 147 of file powershemes.c.

155 {
156  if (ValidatePowerPolicies(0, pp))
157  {
159  uiIndex,
160  dwName,
161  pszName,
162  dwDesc,
163  pszDesc,
164  pp);
165  }
166 
167  return TRUE;
168 }
#define TRUE
Definition: types.h:120
#define pp
Definition: hlsl.yy.c:978
BOOLEAN WINAPI ValidatePowerPolicies(PGLOBAL_POWER_POLICY pGPP, PPOWER_POLICY pPP)
Definition: powrprof.c:851
static PPOWER_SCHEME AddPowerScheme(PPOWER_SCHEMES_PAGE_DATA pPageData, UINT uId, DWORD dwName, LPTSTR pszName, DWORD dwDescription, LPWSTR pszDescription, PPOWER_POLICY pp)
Definition: powershemes.c:64
LPARAM lParam
Definition: combotst.c:139

Referenced by BuildSchemesList().

◆ LoadConfig()

static VOID LoadConfig ( HWND  hwndDlg,
PPOWER_SCHEMES_PAGE_DATA  pPageData,
PPOWER_SCHEME  pScheme 
)
static

Definition at line 237 of file powershemes.c.

241 {
242  INT i = 0, iCurSel = 0;
243  TCHAR szTemp[MAX_PATH];
244  TCHAR szConfig[MAX_PATH];
246  HWND hwndCtrl;
247 
248  if (pScheme == NULL)
249  {
250  iCurSel = (INT)SendDlgItemMessage(hwndDlg,
252  CB_GETCURSEL,
253  0,
254  0);
255  if (iCurSel == CB_ERR)
256  return;
257 
258  pScheme = (PPOWER_SCHEME)SendDlgItemMessage(hwndDlg,
261  (WPARAM)iCurSel,
262  0);
263  if (pScheme == (PPOWER_SCHEME)CB_ERR)
264  return;
265  }
266 
267  pPageData->pSelectedPowerScheme = pScheme;
268 
269  if (LoadString(hApplet, IDS_CONFIG1, szTemp, MAX_PATH))
270  {
271  _stprintf(szConfig, szTemp, pScheme->pszName);
272  SetWindowText(GetDlgItem(hwndDlg, IDC_GRPDETAIL), szConfig);
273  }
274 
275  pp = &pScheme->PowerPolicy;
276 
277  for (i = 0; i < 16; i++)
278  {
279  hwndCtrl = GetDlgItem(hwndDlg, IDC_MONITORACLIST);
280  if (hwndCtrl != NULL && Sec[i] == pp->user.VideoTimeoutAc)
281  {
282  SendMessage(hwndCtrl, CB_SETCURSEL, i, 0);
283  }
284 
285  hwndCtrl = GetDlgItem(hwndDlg, IDC_MONITORDCLIST);
286  if (hwndCtrl != NULL && Sec[i] == pp->user.VideoTimeoutDc)
287  {
288  SendMessage(hwndCtrl, CB_SETCURSEL, i, 0);
289  }
290 
291  hwndCtrl = GetDlgItem(hwndDlg, IDC_DISKACLIST);
292  if (hwndCtrl != NULL && Sec[i] == pp->user.SpindownTimeoutAc)
293  {
294  SendMessage(hwndCtrl, CB_SETCURSEL, i - 2, 0);
295  }
296 
297  hwndCtrl = GetDlgItem(hwndDlg, IDC_DISKDCLIST);
298  if (hwndCtrl != NULL && Sec[i] == pp->user.SpindownTimeoutDc)
299  {
300  SendMessage(hwndCtrl, CB_SETCURSEL, i - 2, 0);
301  }
302 
303  hwndCtrl = GetDlgItem(hwndDlg, IDC_STANDBYACLIST);
304  if (hwndCtrl != NULL && Sec[i] == pp->user.IdleTimeoutAc)
305  {
306  SendMessage(hwndCtrl, CB_SETCURSEL, i, 0);
307  }
308 
309  hwndCtrl = GetDlgItem(hwndDlg, IDC_STANDBYDCLIST);
310  if (hwndCtrl != NULL && Sec[i] == pp->user.IdleTimeoutDc)
311  {
312  SendMessage(hwndCtrl, CB_SETCURSEL, i, 0);
313  }
314 
315  hwndCtrl = GetDlgItem(hwndDlg, IDC_HIBERNATEACLIST);
316  if (hwndCtrl != NULL && Sec[i] == pp->mach.DozeS4TimeoutAc)
317  {
318  SendMessage(hwndCtrl, CB_SETCURSEL, i, 0);
319  }
320 
321  hwndCtrl = GetDlgItem(hwndDlg, IDC_HIBERNATEDCLIST);
322  if (hwndCtrl != NULL && Sec[i] == pp->mach.DozeS4TimeoutDc)
323  {
324  SendMessage(hwndCtrl, CB_SETCURSEL, i, 0);
325  }
326  }
327 
329  (pScheme != pPageData->pActivePowerScheme));
330 }
#define IDC_MONITORACLIST
Definition: resource.h:67
#define IDC_MONITORDCLIST
Definition: resource.h:68
#define CB_GETITEMDATA
Definition: winuser.h:1911
#define INT
Definition: polytest.cpp:20
HINSTANCE hApplet
Definition: access.c:17
struct _POWER_SCHEME * PPOWER_SCHEME
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5708
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1904
#define IDS_CONFIG1
Definition: resource.h:11
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
#define IDC_STANDBYDCLIST
Definition: resource.h:66
LPTSTR pszName
Definition: powershemes.c:19
#define IDC_ENERGYLIST
Definition: resource.h:58
#define pp
Definition: hlsl.yy.c:978
smooth NULL
Definition: ftsmooth.c:416
#define IDC_DISKDCLIST
Definition: resource.h:70
#define CB_ERR
Definition: winuser.h:2389
#define IDC_HIBERNATEACLIST
Definition: resource.h:72
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_HIBERNATEDCLIST
Definition: resource.h:73
#define MAX_PATH
Definition: compat.h:26
#define IDC_STANDBYACLIST
Definition: resource.h:65
#define IDC_DELETE_BTN
Definition: resource.h:67
POWER_POLICY PowerPolicy
Definition: powershemes.c:21
#define CB_SETCURSEL
Definition: winuser.h:1922
PPOWER_SCHEME pSelectedPowerScheme
Definition: powershemes.c:29
UINT Sec[]
Definition: powershemes.c:41
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define _stprintf
Definition: utility.h:124
#define SetWindowText
Definition: winuser.h:5723
#define IDC_GRPDETAIL
Definition: resource.h:59
#define SendMessage
Definition: winuser.h:5709
#define IDC_DISKACLIST
Definition: resource.h:69
#define LoadString
Definition: winuser.h:5685
PPOWER_SCHEME pActivePowerScheme
Definition: powershemes.c:28

Referenced by CreateEnergyList(), DelScheme(), LdrpInitializeProcess(), PowerSchemesDlgProc(), and SaveScheme().

◆ Pos_InitData()

BOOLEAN Pos_InitData ( HWND  hwndDlg)

Definition at line 205 of file powershemes.c.

207 {
209 
210  if (!GetPwrCapabilities(&spc))
211  {
212  return FALSE;
213  }
214 
216  (spc.SystemS1 || spc.SystemS2 || spc.SystemS3) ? SW_SHOW : SW_HIDE);
218  (spc.SystemS1 || spc.SystemS2 || spc.SystemS3) ? SW_SHOW : SW_HIDE);
219  if (spc.SystemBatteriesPresent)
221  (spc.SystemS1 || spc.SystemS2 || spc.SystemS3) ? SW_SHOW : SW_HIDE);
222 
224  (spc.HiberFilePresent) ? SW_SHOW : SW_HIDE);
226  (spc.HiberFilePresent) ? SW_SHOW : SW_HIDE);
227  if (spc.SystemBatteriesPresent)
229  (spc.HiberFilePresent) ? SW_SHOW : SW_HIDE);
230 
231  return TRUE;
232 }
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
BOOLEAN SystemBatteriesPresent
Definition: ntpoapi.h:374
BOOLEAN WINAPI GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)
Definition: powrprof.c:358
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDC_STANDBY
Definition: resource.h:76
#define IDC_STANDBYDCLIST
Definition: resource.h:66
#define SW_SHOW
Definition: winuser.h:769
#define IDC_HIBERNATEACLIST
Definition: resource.h:72
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_HIBERNATEDCLIST
Definition: resource.h:73
#define IDC_STANDBYACLIST
Definition: resource.h:65
#define IDC_HIBERNATE
Definition: resource.h:74

Referenced by PowerSchemesDlgProc().

◆ Pos_InitPage()

static VOID Pos_InitPage ( HWND  hwndDlg)
static

Definition at line 334 of file powershemes.c.

335 {
336  int ifrom = 0, i = 0, imin = 0;
337  HWND hwnd = NULL;
339  LRESULT index;
340 
341  for (i = 1; i < 9; i++)
342  {
343  switch (i)
344  {
345  case 1:
346  hwnd = GetDlgItem(hwndDlg, IDC_MONITORACLIST);
347  imin = IDS_TIMEOUT1;
348  break;
349 
350  case 2:
351  hwnd = GetDlgItem(hwndDlg, IDC_STANDBYACLIST);
352  imin = IDS_TIMEOUT1;
353  break;
354 
355  case 3:
356  hwnd = GetDlgItem(hwndDlg, IDC_DISKACLIST);
357  imin = IDS_TIMEOUT3;
358  break;
359 
360  case 4:
361  hwnd = GetDlgItem(hwndDlg, IDC_HIBERNATEACLIST);
362  imin = IDS_TIMEOUT3;
363  break;
364 
365  case 5:
366  hwnd = GetDlgItem(hwndDlg, IDC_MONITORDCLIST);
367  imin = IDS_TIMEOUT1;
368  break;
369 
370  case 6:
371  hwnd = GetDlgItem(hwndDlg, IDC_STANDBYDCLIST);
372  imin = IDS_TIMEOUT1;
373  break;
374 
375  case 7:
376  hwnd = GetDlgItem(hwndDlg, IDC_DISKDCLIST);
377  imin = IDS_TIMEOUT3;
378  break;
379 
380  case 8:
381  hwnd = GetDlgItem(hwndDlg, IDC_HIBERNATEDCLIST);
382  imin = IDS_TIMEOUT3;
383  break;
384 
385  default:
386  hwnd = NULL;
387  return;
388  }
389 
390  if (hwnd == NULL)
391  continue;
392 
393  for (ifrom = imin; ifrom < (IDS_TIMEOUT15 + 1); ifrom++)
394  {
395  if (LoadString(hApplet, ifrom, szName, MAX_PATH))
396  {
398  CB_ADDSTRING,
399  0,
400  (LPARAM)szName);
401  if (index == CB_ERR)
402  return;
403 
406  index,
407  (LPARAM)Sec[ifrom - IDS_TIMEOUT16]);
408  }
409  }
410 
412  {
414  CB_ADDSTRING,
415  0,
416  (LPARAM)szName);
417  if (index == CB_ERR)
418  return;
419 
422  index,
423  (LPARAM)Sec[0]);
424  }
425  }
426 }
#define CB_SETITEMDATA
Definition: winuser.h:1927
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IDC_MONITORACLIST
Definition: resource.h:67
#define IDS_TIMEOUT1
Definition: resource.h:33
#define IDC_MONITORDCLIST
Definition: resource.h:68
HINSTANCE hApplet
Definition: access.c:17
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
#define IDC_STANDBYDCLIST
Definition: resource.h:66
#define CB_ADDSTRING
Definition: winuser.h:1897
smooth NULL
Definition: ftsmooth.c:416
#define IDC_DISKDCLIST
Definition: resource.h:70
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
#define CB_ERR
Definition: winuser.h:2389
#define IDC_HIBERNATEACLIST
Definition: resource.h:72
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_HIBERNATEDCLIST
Definition: resource.h:73
#define MAX_PATH
Definition: compat.h:26
#define IDC_STANDBYACLIST
Definition: resource.h:65
#define index(s, c)
Definition: various.h:29
UINT Sec[]
Definition: powershemes.c:41
#define IDS_TIMEOUT15
Definition: resource.h:47
#define IDS_TIMEOUT16
Definition: resource.h:32
#define IDS_TIMEOUT3
Definition: resource.h:35
static const WCHAR szName[]
Definition: msipriv.h:1194
#define SendMessage
Definition: winuser.h:5709
#define IDC_DISKACLIST
Definition: resource.h:69
LONG_PTR LRESULT
Definition: windef.h:209
#define LoadString
Definition: winuser.h:5685

Referenced by CreateEnergyList().

◆ Pos_SaveData()

static VOID Pos_SaveData ( HWND  hwndDlg,
PPOWER_SCHEMES_PAGE_DATA  pPageData 
)
static

Definition at line 430 of file powershemes.c.

433 {
434  PPOWER_SCHEME pScheme;
435  HWND hwndCtrl;
436  INT tmp;
437 
438  pScheme = pPageData->pSelectedPowerScheme;
439 
440  hwndCtrl = GetDlgItem(hwndDlg, IDC_MONITORACLIST);
441  if (hwndCtrl != NULL)
442  {
443  tmp = (INT)SendMessage(hwndCtrl, CB_GETCURSEL, 0, 0);
444  if (tmp > 0 && tmp < 16)
445  {
446  pScheme->PowerPolicy.user.VideoTimeoutAc = Sec[tmp];
447  }
448  }
449 
450  hwndCtrl = GetDlgItem(hwndDlg, IDC_MONITORDCLIST);
451  if (hwndCtrl != NULL)
452  {
453  tmp = (INT)SendMessage(hwndCtrl, CB_GETCURSEL, 0, 0);
454  if (tmp > 0 && tmp < 16)
455  {
456  pScheme->PowerPolicy.user.VideoTimeoutDc = Sec[tmp];
457  }
458  }
459 
460  hwndCtrl = GetDlgItem(hwndDlg, IDC_DISKACLIST);
461  if (hwndCtrl != NULL)
462  {
463  tmp = (INT)SendMessage(hwndCtrl, CB_GETCURSEL, 0, 0);
464  if (tmp > 0 && tmp < 16)
465  {
466  pScheme->PowerPolicy.user.SpindownTimeoutAc = Sec[tmp + 2];
467  }
468  }
469 
470  hwndCtrl = GetDlgItem(hwndDlg, IDC_DISKDCLIST);
471  if (hwndCtrl != NULL)
472  {
473  tmp = (INT)SendMessage(hwndCtrl, CB_GETCURSEL, 0, 0);
474  if (tmp > 0 && tmp < 16)
475  {
476  pScheme->PowerPolicy.user.SpindownTimeoutDc = Sec[tmp + 2];
477  }
478  }
479 
480  hwndCtrl = GetDlgItem(hwndDlg, IDC_STANDBYACLIST);
481  if (hwndCtrl != NULL)
482  {
483  tmp = (INT)SendMessage(hwndCtrl, CB_GETCURSEL, 0, 0);
484  if (tmp > 0 && tmp < 16)
485  {
486  pScheme->PowerPolicy.user.IdleTimeoutAc = Sec[tmp];
487  }
488  }
489 
490  hwndCtrl = GetDlgItem(hwndDlg, IDC_STANDBYDCLIST);
491  if (hwndCtrl != NULL)
492  {
493  tmp = (INT)SendMessage(hwndCtrl, CB_GETCURSEL, 0, 0);
494  if (tmp > 0 && tmp < 16)
495  {
496  pScheme->PowerPolicy.user.IdleTimeoutDc = Sec[tmp];
497  }
498  }
499 
500  hwndCtrl = GetDlgItem(hwndDlg, IDC_HIBERNATEACLIST);
501  if (hwndCtrl != NULL)
502  {
503  tmp = (INT)SendMessage(hwndCtrl, CB_GETCURSEL, 0, 0);
504  if (tmp > 0 && tmp < 16)
505  {
506  pScheme->PowerPolicy.mach.DozeS4TimeoutAc = Sec[tmp];
507  }
508  }
509 
510  hwndCtrl = GetDlgItem(hwndDlg, IDC_HIBERNATEDCLIST);
511  if (hwndCtrl != NULL)
512  {
513  tmp = (INT)SendMessage(hwndCtrl, CB_GETCURSEL, 0, 0);
514  if (tmp > 0 && tmp < 16)
515  {
516  pScheme->PowerPolicy.mach.DozeS4TimeoutDc = Sec[tmp];
517  }
518  }
519 
520  if (SetActivePwrScheme(pScheme->uId, NULL, &pScheme->PowerPolicy))
521  {
522  pPageData->pActivePowerScheme = pScheme;
524  }
525 }
#define IDC_MONITORACLIST
Definition: resource.h:67
BOOLEAN WINAPI SetActivePwrScheme(UINT uiID, PGLOBAL_POWER_POLICY lpGlobalPowerPolicy, PPOWER_POLICY lpPowerPolicy)
Definition: powrprof.c:642
#define IDC_MONITORDCLIST
Definition: resource.h:68
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1904
#define IDC_STANDBYDCLIST
Definition: resource.h:66
ULONG SpindownTimeoutDc
Definition: powrprof.h:82
ULONG SpindownTimeoutAc
Definition: powrprof.h:81
smooth NULL
Definition: ftsmooth.c:416
#define IDC_DISKDCLIST
Definition: resource.h:70
MACHINE_POWER_POLICY mach
Definition: powrprof.h:92
#define IDC_HIBERNATEACLIST
Definition: resource.h:72
USER_POWER_POLICY user
Definition: powrprof.h:91
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_HIBERNATEDCLIST
Definition: resource.h:73
ULONG VideoTimeoutAc
Definition: powrprof.h:79
#define IDC_STANDBYACLIST
Definition: resource.h:65
#define IDC_DELETE_BTN
Definition: resource.h:67
POWER_POLICY PowerPolicy
Definition: powershemes.c:21
ULONG VideoTimeoutDc
Definition: powrprof.h:80
PPOWER_SCHEME pSelectedPowerScheme
Definition: powershemes.c:29
UINT Sec[]
Definition: powershemes.c:41
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SendMessage
Definition: winuser.h:5709
ULONG IdleTimeoutDc
Definition: powrprof.h:71
#define IDC_DISKACLIST
Definition: resource.h:69
ULONG IdleTimeoutAc
Definition: powrprof.h:70
PPOWER_SCHEME pActivePowerScheme
Definition: powershemes.c:28

Referenced by PowerSchemesDlgProc(), and SaveScheme().

◆ PowerSchemesDlgProc()

INT_PTR CALLBACK PowerSchemesDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 808 of file powershemes.c.

813 {
814  PPOWER_SCHEMES_PAGE_DATA pPageData;
815 
816  pPageData = (PPOWER_SCHEMES_PAGE_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
817 
818  switch (uMsg)
819  {
820  case WM_INITDIALOG:
823  sizeof(POWER_SCHEMES_PAGE_DATA));
824  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pPageData);
825 
826  BuildSchemesList(pPageData);
827 
828  if (!Pos_InitData(hwndDlg))
829  {
830  // TODO:
831  // Initialization failed
832  // Handle error
833  MessageBox(hwndDlg,_T("Pos_InitData failed\n"), NULL, MB_OK);
834  }
835 
836  if (!CreateEnergyList(hwndDlg, pPageData))
837  {
838  // TODO:
839  // Initialization failed
840  // Handle error
841  MessageBox(hwndDlg,_T("CreateEnergyList failed\n"), NULL, MB_OK);
842  }
843  return TRUE;
844 
845  case WM_DESTROY:
846  if (pPageData)
847  {
848  DestroySchemesList(pPageData);
849  HeapFree(GetProcessHeap(), 0, pPageData);
851  }
852  break;
853 
854  case WM_COMMAND:
855  switch(LOWORD(wParam))
856  {
857  case IDC_ENERGYLIST:
858  if (HIWORD(wParam) == CBN_SELCHANGE)
859  {
860  LoadConfig(hwndDlg, pPageData, NULL);
861  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
862  }
863  break;
864 
865  case IDC_DELETE_BTN:
866  DelScheme(hwndDlg, pPageData);
867  break;
868 
869  case IDC_SAVEAS_BTN:
870  SaveScheme(hwndDlg, pPageData);
871  break;
872 
873  case IDC_MONITORACLIST:
874  case IDC_MONITORDCLIST:
875  case IDC_DISKACLIST:
876  case IDC_DISKDCLIST:
877  case IDC_STANDBYACLIST:
878  case IDC_STANDBYDCLIST:
879  case IDC_HIBERNATEACLIST:
880  case IDC_HIBERNATEDCLIST:
881  if (HIWORD(wParam) == CBN_SELCHANGE)
882  {
883  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
884  }
885  break;
886  }
887  break;
888 
889  case WM_NOTIFY:
890  switch (((LPNMHDR)lParam)->code)
891  {
892  case PSN_APPLY:
893  Pos_SaveData(hwndDlg, pPageData);
894  return TRUE;
895 
896  case PSN_SETACTIVE:
897  Pos_InitData(hwndDlg);
898  return TRUE;
899  }
900  break;
901  }
902 
903  return FALSE;
904 }
struct _POWER_SCHEMES_PAGE_DATA * PPOWER_SCHEMES_PAGE_DATA
#define IDC_MONITORACLIST
Definition: resource.h:67
static VOID SaveScheme(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData)
Definition: powershemes.c:667
#define TRUE
Definition: types.h:120
static VOID Pos_SaveData(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData)
Definition: powershemes.c:430
#define IDC_MONITORDCLIST
Definition: resource.h:68
#define IDC_SAVEAS_BTN
Definition: resource.h:66
#define PSN_APPLY
Definition: prsht.h:117
#define PSN_SETACTIVE
Definition: prsht.h:115
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
struct _POWER_SCHEMES_PAGE_DATA POWER_SCHEMES_PAGE_DATA
static VOID DestroySchemesList(PPOWER_SCHEMES_PAGE_DATA pPageData)
Definition: powershemes.c:183
#define IDC_STANDBYDCLIST
Definition: resource.h:66
#define IDC_ENERGYLIST
Definition: resource.h:58
smooth NULL
Definition: ftsmooth.c:416
#define IDC_DISKDCLIST
Definition: resource.h:70
static BOOL DelScheme(HWND hwnd, PPOWER_SCHEMES_PAGE_DATA pPageData)
Definition: powershemes.c:530
#define WM_DESTROY
Definition: winuser.h:1591
#define IDC_HIBERNATEACLIST
Definition: resource.h:72
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define IDC_HIBERNATEDCLIST
Definition: resource.h:73
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
static VOID LoadConfig(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData, PPOWER_SCHEME pScheme)
Definition: powershemes.c:237
static VOID BuildSchemesList(PPOWER_SCHEMES_PAGE_DATA pPageData)
Definition: powershemes.c:172
#define IDC_STANDBYACLIST
Definition: resource.h:65
#define IDC_DELETE_BTN
Definition: resource.h:67
#define DWLP_USER
Definition: winuser.h:866
#define MessageBox
Definition: winuser.h:5688
#define WM_COMMAND
Definition: winuser.h:1716
static BOOL CreateEnergyList(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData)
Definition: powershemes.c:721
HWND WINAPI GetParent(_In_ HWND)
BOOLEAN Pos_InitData(HWND hwndDlg)
Definition: powershemes.c:205
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define MB_OK
Definition: winuser.h:784
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CBN_SELCHANGE
Definition: winuser.h:1940
#define HIWORD(l)
Definition: typedefs.h:246
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDC_DISKACLIST
Definition: resource.h:69
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by Applet1().

◆ SavePowerScheme()

static BOOL SavePowerScheme ( HWND  hwndDlg,
PSAVE_POWER_SCHEME_DATA  pSaveSchemeData 
)
static

Definition at line 584 of file powershemes.c.

587 {
588  PPOWER_SCHEMES_PAGE_DATA pPageData;
589  PPOWER_SCHEME pScheme;
590  TCHAR szSchemeName[512];
591  BOOL bRet = FALSE;
592 
593  pPageData = pSaveSchemeData->pPageData;
594 
595  GetDlgItemText(hwndDlg, IDC_SCHEMENAME, szSchemeName, ARRAYSIZE(szSchemeName));
596 
597  pScheme = AddPowerScheme(pPageData,
598  -1,
599  (_tcslen(szSchemeName) + 1) * sizeof(TCHAR),
600  szSchemeName,
601  sizeof(TCHAR),
602  TEXT(""),
603  &pPageData->pSelectedPowerScheme->PowerPolicy);
604  if (pScheme != NULL)
605  {
606  if (WritePwrScheme(&pScheme->uId,
607  pScheme->pszName,
608  pScheme->pszDescription,
609  &pScheme->PowerPolicy))
610  {
611  pSaveSchemeData->pNewScheme = pScheme;
612  bRet = TRUE;
613  }
614  else
615  {
616  DeletePowerScheme(pScheme);
617  }
618  }
619 
620  return bRet;
621 }
#define TRUE
Definition: types.h:120
#define IDC_SCHEMENAME
Definition: resource.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LPTSTR pszName
Definition: powershemes.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
static VOID DeletePowerScheme(PPOWER_SCHEME pScheme)
Definition: powershemes.c:129
char TCHAR
Definition: xmlstorage.h:189
#define GetDlgItemText
Definition: winuser.h:5651
BOOLEAN WINAPI WritePwrScheme(PUINT puiID, LPWSTR lpszName, LPWSTR lpszDescription, PPOWER_POLICY pPowerPolicy)
Definition: powrprof.c:766
POWER_POLICY PowerPolicy
Definition: powershemes.c:21
PPOWER_SCHEME pSelectedPowerScheme
Definition: powershemes.c:29
LPTSTR pszDescription
Definition: powershemes.c:20
#define TEXT(s)
Definition: k32.h:26
static PPOWER_SCHEME AddPowerScheme(PPOWER_SCHEMES_PAGE_DATA pPageData, UINT uId, DWORD dwName, LPTSTR pszName, DWORD dwDescription, LPWSTR pszDescription, PPOWER_POLICY pp)
Definition: powershemes.c:64
PPOWER_SCHEME pNewScheme
Definition: powershemes.c:36
PPOWER_SCHEMES_PAGE_DATA pPageData
Definition: powershemes.c:35

Referenced by SaveSchemeDlgProc().

◆ SaveScheme()

static VOID SaveScheme ( HWND  hwndDlg,
PPOWER_SCHEMES_PAGE_DATA  pPageData 
)
static

Definition at line 667 of file powershemes.c.

670 {
671  SAVE_POWER_SCHEME_DATA SaveSchemeData;
672  POWER_POLICY BackupPowerPolicy;
673  HWND hwndList;
674  INT index;
675 
676  SaveSchemeData.pPageData = pPageData;
677  SaveSchemeData.pNewScheme = NULL;
678  SaveSchemeData.hwndPage = hwndDlg;
679 
680  CopyMemory(&BackupPowerPolicy,
681  &pPageData->pSelectedPowerScheme->PowerPolicy,
682  sizeof(POWER_POLICY));
683 
684  Pos_SaveData(hwndDlg, pPageData);
685 
688  hwndDlg,
690  (LPARAM)&SaveSchemeData))
691  {
692  if (SaveSchemeData.pNewScheme)
693  {
694  hwndList = GetDlgItem(hwndDlg, IDC_ENERGYLIST);
695 
696  index = (INT)SendMessage(hwndList,
697  CB_ADDSTRING,
698  0,
699  (LPARAM)SaveSchemeData.pNewScheme->pszName);
700  if (index != CB_ERR)
701  {
702  SendMessage(hwndList,
704  index,
705  (LPARAM)SaveSchemeData.pNewScheme);
706 
707  SendMessage(hwndList, CB_SETCURSEL, (WPARAM)index, 0);
708 
709  LoadConfig(hwndDlg, pPageData, SaveSchemeData.pNewScheme);
710  }
711  }
712  }
713 
715  &BackupPowerPolicy,
716  sizeof(POWER_POLICY));
717 }
#define CB_SETITEMDATA
Definition: winuser.h:1927
#define MAKEINTRESOURCE
Definition: winuser.h:591
static VOID Pos_SaveData(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData)
Definition: powershemes.c:430
#define INT
Definition: polytest.cpp:20
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT
Definition: typedefs.h:56
#define IDC_ENERGYLIST
Definition: resource.h:58
#define CB_ADDSTRING
Definition: winuser.h:1897
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
#define CB_ERR
Definition: winuser.h:2389
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CopyMemory
Definition: winbase.h:1633
static VOID LoadConfig(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData, PPOWER_SCHEME pScheme)
Definition: powershemes.c:237
#define DialogBoxParam
Definition: winuser.h:5630
#define index(s, c)
Definition: various.h:29
POWER_POLICY PowerPolicy
Definition: powershemes.c:21
#define CB_SETCURSEL
Definition: winuser.h:1922
PPOWER_SCHEME pSelectedPowerScheme
Definition: powershemes.c:29
#define IDD_SAVEPOWERSCHEME
Definition: resource.h:20
#define SendMessage
Definition: winuser.h:5709
PPOWER_SCHEME pNewScheme
Definition: powershemes.c:36
INT_PTR CALLBACK SaveSchemeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: powershemes.c:626
PPOWER_SCHEMES_PAGE_DATA pPageData
Definition: powershemes.c:35

Referenced by PowerSchemesDlgProc().

◆ SaveSchemeDlgProc()

INT_PTR CALLBACK SaveSchemeDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 626 of file powershemes.c.

631 {
632  PSAVE_POWER_SCHEME_DATA pSaveSchemeData;
633 
634  pSaveSchemeData = (PSAVE_POWER_SCHEME_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
635 
636  switch (uMsg)
637  {
638  case WM_INITDIALOG:
639  pSaveSchemeData = (PSAVE_POWER_SCHEME_DATA)lParam;
640  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pSaveSchemeData);
641 
642  SetDlgItemText(hwndDlg,
644  pSaveSchemeData->pPageData->pSelectedPowerScheme->pszName);
645  return TRUE;
646 
647  case WM_COMMAND:
648  switch(LOWORD(wParam))
649  {
650  case IDOK:
651  EndDialog(hwndDlg, SavePowerScheme(hwndDlg, pSaveSchemeData));
652  break;
653 
654  case IDCANCEL:
655  EndDialog(hwndDlg, FALSE);
656  break;
657  }
658  break;
659  }
660 
661  return FALSE;
662 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define IDC_SCHEMENAME
Definition: resource.h:112
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
LPTSTR pszName
Definition: powershemes.c:19
struct _SAVE_POWER_SCHEME_DATA * PSAVE_POWER_SCHEME_DATA
static BOOL SavePowerScheme(HWND hwndDlg, PSAVE_POWER_SCHEME_DATA pSaveSchemeData)
Definition: powershemes.c:584
#define SetDlgItemText
Definition: winuser.h:5715
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1716
PPOWER_SCHEME pSelectedPowerScheme
Definition: powershemes.c:29
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
PPOWER_SCHEMES_PAGE_DATA pPageData
Definition: powershemes.c:35

Referenced by SaveScheme().

Variable Documentation

◆ Sec

UINT Sec[]
Initial value:
=
{
60,
120,
180,
300,
600,
900,
1200,
1500,
1800,
2700,
3600,
7200,
10800,
14400,
18000,
0
}

Definition at line 41 of file powershemes.c.

Referenced by LoadConfig(), Pos_InitPage(), Pos_SaveData(), and SetScreenSaver().