3 * PROJECT: ReactOS Power Configuration Applet
4 * LICENSE: GPL - See COPYING in the top level directory
5 * FILE: dll/cpl/powercfg/powershemes.c
6 * PURPOSE: initialization of applet
7 * PROGRAMMERS: Alexander Wurzinger (Lohnegrim at gmx dot net)
8 * Johannes Anderwald (johannes.anderwald@student.tugraz.at)
10 * Dmitry Chapyshev (lentind@yandex.ru)
22 #define NUM_APPLETS (1)
24 static LONG APIENTRY
Applet1(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
);
27 HINSTANCE hApplet
= 0;
28 GLOBAL_POWER_POLICY gGPP
;
32 APPLET Applets
[NUM_APPLETS
] =
34 {IDC_CPLICON_1
, IDS_CPLNAME_1
, IDS_CPLDESCRIPTION_1
, Applet1
}
38 PropSheetAddPage(HPROPSHEETPAGE hpage
, LPARAM lParam
)
40 PROPSHEETHEADER
*ppsh
= (PROPSHEETHEADER
*)lParam
;
41 if (ppsh
!= NULL
&& ppsh
->nPages
< MAX_POWER_PAGES
)
43 ppsh
->phpage
[ppsh
->nPages
++] = hpage
;
51 InitPropSheetPage(PROPSHEETHEADER
*ppsh
, WORD idDlg
, DLGPROC DlgProc
)
56 if (ppsh
->nPages
< MAX_POWER_PAGES
)
58 ZeroMemory(&psp
, sizeof(psp
));
59 psp
.dwSize
= sizeof(psp
);
60 psp
.dwFlags
= PSP_DEFAULT
;
61 psp
.hInstance
= hApplet
;
62 psp
.pszTemplate
= MAKEINTRESOURCE(idDlg
);
63 psp
.pfnDlgProc
= DlgProc
;
65 hPage
= CreatePropertySheetPage(&psp
);
68 return PropSheetAddPage(hPage
, (LPARAM
)ppsh
);
78 Applet1(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
80 HPROPSHEETPAGE hpsp
[MAX_POWER_PAGES
];
84 SYSTEM_POWER_CAPABILITIES spc
;
87 UNREFERENCED_PARAMETER(hwnd
);
88 UNREFERENCED_PARAMETER(uMsg
);
89 UNREFERENCED_PARAMETER(wParam
);
90 UNREFERENCED_PARAMETER(lParam
);
92 memset(Caption
, 0x0, sizeof(Caption
));
93 LoadString(hApplet
, IDS_CPLNAME_1
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
95 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
96 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
97 psh
.dwFlags
= PSH_PROPTITLE
;
98 psh
.hwndParent
= NULL
;
99 psh
.hInstance
= hApplet
;
100 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_CPLICON_1
));
101 psh
.pszCaption
= Caption
;
106 InitPropSheetPage(&psh
, IDD_PROPPAGEPOWERSHEMES
, (DLGPROC
)PowerSchemesDlgProc
);
107 if (GetPwrCapabilities(&spc
))
109 if (spc
.SystemBatteriesPresent
)
111 InitPropSheetPage(&psh
, IDD_PROPPAGEALARMS
, (DLGPROC
)AlarmsDlgProc
);
114 InitPropSheetPage(&psh
, IDD_PROPPAGEADVANCED
, (DLGPROC
)AdvancedDlgProc
);
115 InitPropSheetPage(&psh
, IDD_PROPPAGEHIBERNATE
, (DLGPROC
)HibernateDlgProc
);
117 /* Load additional pages provided by shell extensions */
118 hpsxa
= SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE
, REGSTR_PATH_CONTROLSFOLDER
TEXT("\\Power"), MAX_POWER_PAGES
- psh
.nPages
);
120 SHAddFromPropSheetExtArray(hpsxa
, PropSheetAddPage
, (LPARAM
)&psh
);
122 ret
= (LONG
)(PropertySheet(&psh
) != -1);
125 SHDestroyPropSheetExtArray(hpsxa
);
130 /* Control Panel Callback */
132 CPlApplet(HWND hwndCPl
,
137 int i
= (int)lParam1
;
151 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
153 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
154 CPlInfo
->idName
= Applets
[i
].idName
;
155 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
160 Applets
[i
].AppletProc(hwndCPl
, uMsg
, lParam1
, lParam2
);
169 DllMain(HINSTANCE hinstDLL
,
173 UNREFERENCED_PARAMETER(lpvReserved
);
176 case DLL_PROCESS_ATTACH
:
177 case DLL_THREAD_ATTACH
: