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)
15 #define NUM_APPLETS (1)
17 static LONG APIENTRY
Applet1(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
);
20 HINSTANCE hApplet
= 0;
21 GLOBAL_POWER_POLICY gGPP
;
25 APPLET Applets
[NUM_APPLETS
] =
27 {IDC_CPLICON_1
, IDS_CPLNAME_1
, IDS_CPLDESCRIPTION_1
, Applet1
}
31 PropSheetAddPage(HPROPSHEETPAGE hpage
, LPARAM lParam
)
33 PROPSHEETHEADER
*ppsh
= (PROPSHEETHEADER
*)lParam
;
34 if (ppsh
!= NULL
&& ppsh
->nPages
< MAX_POWER_PAGES
)
36 ppsh
->phpage
[ppsh
->nPages
++] = hpage
;
44 InitPropSheetPage(PROPSHEETHEADER
*ppsh
, WORD idDlg
, DLGPROC DlgProc
)
49 if (ppsh
->nPages
< MAX_POWER_PAGES
)
51 ZeroMemory(&psp
, sizeof(psp
));
52 psp
.dwSize
= sizeof(psp
);
53 psp
.dwFlags
= PSP_DEFAULT
;
54 psp
.hInstance
= hApplet
;
55 psp
.pszTemplate
= MAKEINTRESOURCE(idDlg
);
56 psp
.pfnDlgProc
= DlgProc
;
58 hPage
= CreatePropertySheetPage(&psp
);
61 return PropSheetAddPage(hPage
, (LPARAM
)ppsh
);
71 Applet1(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
73 HPROPSHEETPAGE hpsp
[MAX_POWER_PAGES
];
77 SYSTEM_POWER_CAPABILITIES spc
;
80 UNREFERENCED_PARAMETER(uMsg
);
81 UNREFERENCED_PARAMETER(wParam
);
82 UNREFERENCED_PARAMETER(lParam
);
84 memset(Caption
, 0x0, sizeof(Caption
));
85 LoadString(hApplet
, IDS_CPLNAME_1
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
87 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
88 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
89 psh
.dwFlags
= PSH_PROPTITLE
;
90 psh
.hwndParent
= hwnd
;
91 psh
.hInstance
= hApplet
;
92 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_CPLICON_1
));
93 psh
.pszCaption
= Caption
;
98 InitPropSheetPage(&psh
, IDD_PROPPAGEPOWERSHEMES
, (DLGPROC
)PowerSchemesDlgProc
);
99 if (GetPwrCapabilities(&spc
))
101 if (spc
.SystemBatteriesPresent
)
103 InitPropSheetPage(&psh
, IDD_PROPPAGEALARMS
, (DLGPROC
)AlarmsDlgProc
);
106 InitPropSheetPage(&psh
, IDD_PROPPAGEADVANCED
, (DLGPROC
)AdvancedDlgProc
);
107 InitPropSheetPage(&psh
, IDD_PROPPAGEHIBERNATE
, (DLGPROC
)HibernateDlgProc
);
109 /* Load additional pages provided by shell extensions */
110 hpsxa
= SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE
, REGSTR_PATH_CONTROLSFOLDER
TEXT("\\Power"), MAX_POWER_PAGES
- psh
.nPages
);
112 SHAddFromPropSheetExtArray(hpsxa
, PropSheetAddPage
, (LPARAM
)&psh
);
114 ret
= (LONG
)(PropertySheet(&psh
) != -1);
117 SHDestroyPropSheetExtArray(hpsxa
);
122 /* Control Panel Callback */
124 CPlApplet(HWND hwndCPl
,
129 int i
= (int)lParam1
;
143 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
145 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
146 CPlInfo
->idName
= Applets
[i
].idName
;
147 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
152 Applets
[i
].AppletProc(hwndCPl
, uMsg
, lParam1
, lParam2
);
161 DllMain(HINSTANCE hinstDLL
,
165 UNREFERENCED_PARAMETER(lpvReserved
);
168 case DLL_PROCESS_ATTACH
:
169 case DLL_THREAD_ATTACH
: