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
);
25 INT_PTR CALLBACK
powershemesProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
26 INT_PTR CALLBACK
alarmsProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
27 INT_PTR CALLBACK
advancedProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
28 INT_PTR CALLBACK
hibernateProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
30 HINSTANCE hApplet
= 0;
31 GLOBAL_POWER_POLICY gGPP
;
35 APPLET Applets
[NUM_APPLETS
] =
37 {IDC_CPLICON_1
, IDS_CPLNAME_1
, IDS_CPLDESCRIPTION_1
, Applet1
}
41 PropSheetAddPage(HPROPSHEETPAGE hpage
, LPARAM lParam
)
43 PROPSHEETHEADER
*ppsh
= (PROPSHEETHEADER
*)lParam
;
44 if (ppsh
!= NULL
&& ppsh
->nPages
< MAX_POWER_PAGES
)
46 ppsh
->phpage
[ppsh
->nPages
++] = hpage
;
54 InitPropSheetPage(PROPSHEETHEADER
*ppsh
, WORD idDlg
, DLGPROC DlgProc
)
59 if (ppsh
->nPages
< MAX_POWER_PAGES
)
61 ZeroMemory(&psp
, sizeof(psp
));
62 psp
.dwSize
= sizeof(psp
);
63 psp
.dwFlags
= PSP_DEFAULT
;
64 psp
.hInstance
= hApplet
;
65 psp
.pszTemplate
= MAKEINTRESOURCE(idDlg
);
66 psp
.pfnDlgProc
= DlgProc
;
68 hPage
= CreatePropertySheetPage(&psp
);
71 return PropSheetAddPage(hPage
, (LPARAM
)ppsh
);
79 /* Property Sheet Callback */
87 UNREFERENCED_PARAMETER(hwndDlg
);
90 case PSCB_BUTTONPRESSED
:
93 case PSBTN_OK
: /* OK */
95 case PSBTN_CANCEL
: /* Cancel */
97 case PSBTN_APPLYNOW
: /* Apply now */
99 case PSBTN_FINISH
: /* Close */
106 case PSCB_INITIALIZED
:
114 Applet1(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
116 HPROPSHEETPAGE hpsp
[MAX_POWER_PAGES
];
120 SYSTEM_POWER_CAPABILITIES spc
;
123 UNREFERENCED_PARAMETER(hwnd
);
124 UNREFERENCED_PARAMETER(uMsg
);
125 UNREFERENCED_PARAMETER(wParam
);
126 UNREFERENCED_PARAMETER(lParam
);
128 memset(Caption
, 0x0, sizeof(Caption
));
129 LoadString(hApplet
, IDS_CPLNAME_1
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
131 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
132 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
133 psh
.dwFlags
= PSH_USECALLBACK
| PSH_PROPTITLE
;
134 psh
.hwndParent
= NULL
;
135 psh
.hInstance
= hApplet
;
136 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_CPLICON_1
));
137 psh
.pszCaption
= Caption
;
141 psh
.pfnCallback
= PropSheetProc
;
143 InitPropSheetPage(&psh
, IDD_PROPPAGEPOWERSHEMES
, (DLGPROC
) powershemesProc
);
144 if (GetPwrCapabilities(&spc
))
146 if (spc
.SystemBatteriesPresent
)
148 InitPropSheetPage(&psh
, IDD_PROPPAGEALARMS
, (DLGPROC
) alarmsProc
);
151 InitPropSheetPage(&psh
, IDD_PROPPAGEADVANCED
, (DLGPROC
) advancedProc
);
152 InitPropSheetPage(&psh
, IDD_PROPPAGEHIBERNATE
, (DLGPROC
) hibernateProc
);
154 /* Load additional pages provided by shell extensions */
155 hpsxa
= SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE
, REGSTR_PATH_CONTROLSFOLDER
TEXT("\\Power"), MAX_POWER_PAGES
- psh
.nPages
);
157 SHAddFromPropSheetExtArray(hpsxa
, PropSheetAddPage
, (LPARAM
)&psh
);
159 ret
= (LONG
)(PropertySheet(&psh
) != -1);
162 SHDestroyPropSheetExtArray(hpsxa
);
167 /* Control Panel Callback */
175 int i
= (int)lParam1
;
189 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
191 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
192 CPlInfo
->idName
= Applets
[i
].idName
;
193 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
198 Applets
[i
].AppletProc(hwndCPl
, uMsg
, lParam1
, lParam2
);
213 UNREFERENCED_PARAMETER(lpvReserved
);
216 case DLL_PROCESS_ATTACH
:
217 case DLL_THREAD_ATTACH
: