2013-03-16 20:25:38 +00:00
|
|
|
/*
|
2006-06-15 14:16:29 +00:00
|
|
|
* PROJECT: ReactOS Power Configuration Applet
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: dll/cpl/powercfg/powershemes.c
|
|
|
|
* PURPOSE: initialization of applet
|
|
|
|
* PROGRAMMERS: Alexander Wurzinger (Lohnegrim at gmx dot net)
|
2013-09-15 13:06:05 +00:00
|
|
|
* Johannes Anderwald (johannes.anderwald@reactos.org)
|
2006-06-15 14:16:29 +00:00
|
|
|
* Martin Rottensteiner
|
2007-11-30 18:52:33 +00:00
|
|
|
* Dmitry Chapyshev (lentind@yandex.ru)
|
2006-06-15 14:16:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "powercfg.h"
|
|
|
|
|
2014-01-19 10:37:02 +00:00
|
|
|
#include <winreg.h>
|
|
|
|
#include <regstr.h>
|
|
|
|
|
2006-06-15 14:16:29 +00:00
|
|
|
#define NUM_APPLETS (1)
|
|
|
|
|
2007-07-28 20:02:37 +00:00
|
|
|
static LONG APIENTRY Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
|
2007-12-02 14:25:17 +00:00
|
|
|
|
2006-06-15 14:16:29 +00:00
|
|
|
|
|
|
|
HINSTANCE hApplet = 0;
|
|
|
|
GLOBAL_POWER_POLICY gGPP;
|
2006-06-23 17:14:29 +00:00
|
|
|
TCHAR langSel[255];
|
2006-06-15 14:16:29 +00:00
|
|
|
|
|
|
|
/* Applets */
|
2007-10-19 23:21:45 +00:00
|
|
|
APPLET Applets[NUM_APPLETS] =
|
2006-06-15 14:16:29 +00:00
|
|
|
{
|
|
|
|
{IDC_CPLICON_1, IDS_CPLNAME_1, IDS_CPLDESCRIPTION_1, Applet1}
|
|
|
|
};
|
|
|
|
|
2007-09-22 18:59:23 +00:00
|
|
|
static BOOL CALLBACK
|
|
|
|
PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
|
|
|
|
{
|
|
|
|
PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
|
|
|
|
if (ppsh != NULL && ppsh->nPages < MAX_POWER_PAGES)
|
|
|
|
{
|
|
|
|
ppsh->phpage[ppsh->nPages++] = hpage;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
|
2006-06-15 14:16:29 +00:00
|
|
|
{
|
2007-09-22 18:59:23 +00:00
|
|
|
HPROPSHEETPAGE hPage;
|
|
|
|
PROPSHEETPAGE psp;
|
|
|
|
|
|
|
|
if (ppsh->nPages < MAX_POWER_PAGES)
|
|
|
|
{
|
|
|
|
ZeroMemory(&psp, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = PSP_DEFAULT;
|
|
|
|
psp.hInstance = hApplet;
|
|
|
|
psp.pszTemplate = MAKEINTRESOURCE(idDlg);
|
|
|
|
psp.pfnDlgProc = DlgProc;
|
|
|
|
|
|
|
|
hPage = CreatePropertySheetPage(&psp);
|
|
|
|
if (hPage != NULL)
|
|
|
|
{
|
|
|
|
return PropSheetAddPage(hPage, (LPARAM)ppsh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2006-06-15 14:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* First Applet */
|
2007-07-28 20:02:37 +00:00
|
|
|
static LONG APIENTRY
|
2007-10-19 23:21:45 +00:00
|
|
|
Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
|
2006-06-15 14:16:29 +00:00
|
|
|
{
|
2007-09-22 18:59:23 +00:00
|
|
|
HPROPSHEETPAGE hpsp[MAX_POWER_PAGES];
|
2006-06-15 14:16:29 +00:00
|
|
|
PROPSHEETHEADER psh;
|
2007-09-22 18:48:02 +00:00
|
|
|
HPSXA hpsxa = NULL;
|
2006-06-15 14:16:29 +00:00
|
|
|
TCHAR Caption[1024];
|
|
|
|
SYSTEM_POWER_CAPABILITIES spc;
|
2007-09-22 18:48:02 +00:00
|
|
|
LONG ret;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-07-09 21:10:40 +00:00
|
|
|
UNREFERENCED_PARAMETER(uMsg);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
2006-06-23 18:44:57 +00:00
|
|
|
|
2006-06-15 14:16:29 +00:00
|
|
|
memset(Caption, 0x0, sizeof(Caption));
|
|
|
|
LoadString(hApplet, IDS_CPLNAME_1, Caption, sizeof(Caption) / sizeof(TCHAR));
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-06-15 14:16:29 +00:00
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
2007-12-02 14:25:17 +00:00
|
|
|
psh.dwFlags = PSH_PROPTITLE;
|
2008-05-15 05:43:01 +00:00
|
|
|
psh.hwndParent = hwnd;
|
2006-06-15 14:16:29 +00:00
|
|
|
psh.hInstance = hApplet;
|
|
|
|
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON_1));
|
|
|
|
psh.pszCaption = Caption;
|
2007-09-22 18:59:23 +00:00
|
|
|
psh.nPages = 0;
|
2006-06-15 14:16:29 +00:00
|
|
|
psh.nStartPage = 0;
|
2007-09-22 18:59:23 +00:00
|
|
|
psh.phpage = hpsp;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-12-02 14:25:17 +00:00
|
|
|
InitPropSheetPage(&psh, IDD_PROPPAGEPOWERSHEMES, (DLGPROC)PowerSchemesDlgProc);
|
2006-06-15 14:16:29 +00:00
|
|
|
if (GetPwrCapabilities(&spc))
|
|
|
|
{
|
|
|
|
if (spc.SystemBatteriesPresent)
|
|
|
|
{
|
2007-12-02 14:25:17 +00:00
|
|
|
InitPropSheetPage(&psh, IDD_PROPPAGEALARMS, (DLGPROC)AlarmsDlgProc);
|
2006-06-15 14:16:29 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-02 14:25:17 +00:00
|
|
|
InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, (DLGPROC)AdvancedDlgProc);
|
|
|
|
InitPropSheetPage(&psh, IDD_PROPPAGEHIBERNATE, (DLGPROC)HibernateDlgProc);
|
2007-09-22 18:48:02 +00:00
|
|
|
|
|
|
|
/* Load additional pages provided by shell extensions */
|
|
|
|
hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Power"), MAX_POWER_PAGES - psh.nPages);
|
|
|
|
if (hpsxa != NULL)
|
|
|
|
SHAddFromPropSheetExtArray(hpsxa, PropSheetAddPage, (LPARAM)&psh);
|
|
|
|
|
|
|
|
ret = (LONG)(PropertySheet(&psh) != -1);
|
|
|
|
|
|
|
|
if (hpsxa != NULL)
|
|
|
|
SHDestroyPropSheetExtArray(hpsxa);
|
|
|
|
|
|
|
|
return ret;
|
2006-06-15 14:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Control Panel Callback */
|
|
|
|
LONG CALLBACK
|
2007-12-02 14:25:17 +00:00
|
|
|
CPlApplet(HWND hwndCPl,
|
|
|
|
UINT uMsg,
|
|
|
|
LPARAM lParam1,
|
|
|
|
LPARAM lParam2)
|
2006-06-15 14:16:29 +00:00
|
|
|
{
|
|
|
|
int i = (int)lParam1;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-06-15 14:16:29 +00:00
|
|
|
switch(uMsg)
|
|
|
|
{
|
|
|
|
case CPL_INIT:
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case CPL_GETCOUNT:
|
|
|
|
{
|
|
|
|
return NUM_APPLETS;
|
|
|
|
}
|
|
|
|
case CPL_INQUIRE:
|
|
|
|
{
|
|
|
|
CPLINFO *CPlInfo = (CPLINFO*)lParam2;
|
|
|
|
CPlInfo->lData = 0;
|
|
|
|
CPlInfo->idIcon = Applets[i].idIcon;
|
|
|
|
CPlInfo->idName = Applets[i].idName;
|
|
|
|
CPlInfo->idInfo = Applets[i].idDescription;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CPL_DBLCLK:
|
|
|
|
{
|
|
|
|
Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-02 14:25:17 +00:00
|
|
|
BOOLEAN WINAPI
|
|
|
|
DllMain(HINSTANCE hinstDLL,
|
|
|
|
DWORD dwReason,
|
|
|
|
LPVOID lpvReserved)
|
2006-06-15 14:16:29 +00:00
|
|
|
{
|
2006-07-09 21:10:40 +00:00
|
|
|
UNREFERENCED_PARAMETER(lpvReserved);
|
2006-06-15 14:16:29 +00:00
|
|
|
switch(dwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
case DLL_THREAD_ATTACH:
|
|
|
|
hApplet = hinstDLL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|