2 * PROJECT: ReactOS Power Configuration Applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/powercfg/powershemes.c
5 * PURPOSE: initialization of applet
6 * PROGRAMMERS: Alexander Wurzinger (Lohnegrim at gmx dot net)
7 * Johannes Anderwald (johannes.anderwald@reactos.org)
9 * Dmitry Chapyshev (lentind@yandex.ru)
17 #define NUM_APPLETS (1)
19 static LONG APIENTRY
Applet1(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
);
22 HINSTANCE hApplet
= 0;
23 GLOBAL_POWER_POLICY gGPP
;
27 APPLET Applets
[NUM_APPLETS
] =
29 {IDC_CPLICON_1
, IDS_CPLNAME_1
, IDS_CPLDESCRIPTION_1
, Applet1
}
33 PropSheetAddPage(HPROPSHEETPAGE hpage
, LPARAM lParam
)
35 PROPSHEETHEADER
*ppsh
= (PROPSHEETHEADER
*)lParam
;
36 if (ppsh
!= NULL
&& ppsh
->nPages
< MAX_POWER_PAGES
)
38 ppsh
->phpage
[ppsh
->nPages
++] = hpage
;
46 InitPropSheetPage(PROPSHEETHEADER
*ppsh
, WORD idDlg
, DLGPROC DlgProc
)
51 if (ppsh
->nPages
< MAX_POWER_PAGES
)
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
;
60 hPage
= CreatePropertySheetPage(&psp
);
63 return PropSheetAddPage(hPage
, (LPARAM
)ppsh
);
73 Applet1(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
75 HPROPSHEETPAGE hpsp
[MAX_POWER_PAGES
];
79 SYSTEM_POWER_CAPABILITIES spc
;
82 UNREFERENCED_PARAMETER(uMsg
);
83 UNREFERENCED_PARAMETER(wParam
);
84 UNREFERENCED_PARAMETER(lParam
);
86 memset(Caption
, 0x0, sizeof(Caption
));
87 LoadString(hApplet
, IDS_CPLNAME_1
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
89 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
90 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
91 psh
.dwFlags
= PSH_PROPTITLE
;
92 psh
.hwndParent
= hwnd
;
93 psh
.hInstance
= hApplet
;
94 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_CPLICON_1
));
95 psh
.pszCaption
= Caption
;
100 InitPropSheetPage(&psh
, IDD_PROPPAGEPOWERSHEMES
, (DLGPROC
)PowerSchemesDlgProc
);
101 if (GetPwrCapabilities(&spc
))
103 if (spc
.SystemBatteriesPresent
)
105 InitPropSheetPage(&psh
, IDD_PROPPAGEALARMS
, (DLGPROC
)AlarmsDlgProc
);
108 InitPropSheetPage(&psh
, IDD_PROPPAGEADVANCED
, (DLGPROC
)AdvancedDlgProc
);
109 InitPropSheetPage(&psh
, IDD_PROPPAGEHIBERNATE
, (DLGPROC
)HibernateDlgProc
);
111 /* Load additional pages provided by shell extensions */
112 hpsxa
= SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE
, REGSTR_PATH_CONTROLSFOLDER
TEXT("\\Power"), MAX_POWER_PAGES
- psh
.nPages
);
114 SHAddFromPropSheetExtArray(hpsxa
, PropSheetAddPage
, (LPARAM
)&psh
);
116 ret
= (LONG
)(PropertySheet(&psh
) != -1);
119 SHDestroyPropSheetExtArray(hpsxa
);
124 /* Control Panel Callback */
126 CPlApplet(HWND hwndCPl
,
131 int i
= (int)lParam1
;
145 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
147 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
148 CPlInfo
->idName
= Applets
[i
].idName
;
149 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
154 Applets
[i
].AppletProc(hwndCPl
, uMsg
, lParam1
, lParam2
);
163 DllMain(HINSTANCE hinstDLL
,
167 UNREFERENCED_PARAMETER(lpvReserved
);
170 case DLL_PROCESS_ATTACH
:
171 case DLL_THREAD_ATTACH
: