2 * PROJECT: ReactOS Power Configuration Applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/powercfg/powercfg.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
);
71 PropSheetProc(HWND hwndDlg
, UINT uMsg
, LPARAM lParam
)
73 // NOTE: This callback is needed to set large icon correctly.
78 case PSCB_INITIALIZED
:
80 hIcon
= LoadIconW(hApplet
, MAKEINTRESOURCEW(IDC_CPLICON_1
));
81 SendMessageW(hwndDlg
, WM_SETICON
, ICON_BIG
, (LPARAM
)hIcon
);
90 Applet1(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
92 HPROPSHEETPAGE hpsp
[MAX_POWER_PAGES
];
96 SYSTEM_POWER_CAPABILITIES spc
;
99 UNREFERENCED_PARAMETER(uMsg
);
100 UNREFERENCED_PARAMETER(wParam
);
101 UNREFERENCED_PARAMETER(lParam
);
103 memset(Caption
, 0x0, sizeof(Caption
));
104 LoadString(hApplet
, IDS_CPLNAME_1
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
106 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
107 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
108 psh
.dwFlags
= PSH_PROPTITLE
| PSH_USEICONID
| PSH_USECALLBACK
;
109 psh
.hwndParent
= hwnd
;
110 psh
.hInstance
= hApplet
;
111 psh
.pszIcon
= MAKEINTRESOURCEW(IDC_CPLICON_1
);
112 psh
.pszCaption
= Caption
;
116 psh
.pfnCallback
= PropSheetProc
;
118 InitPropSheetPage(&psh
, IDD_PROPPAGEPOWERSCHEMES
, PowerSchemesDlgProc
);
119 if (GetPwrCapabilities(&spc
))
121 if (spc
.SystemBatteriesPresent
)
123 InitPropSheetPage(&psh
, IDD_PROPPAGEALARMS
, AlarmsDlgProc
);
126 InitPropSheetPage(&psh
, IDD_PROPPAGEADVANCED
, AdvancedDlgProc
);
127 InitPropSheetPage(&psh
, IDD_PROPPAGEHIBERNATE
, HibernateDlgProc
);
129 /* Load additional pages provided by shell extensions */
130 hpsxa
= SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE
, REGSTR_PATH_CONTROLSFOLDER
TEXT("\\Power"), MAX_POWER_PAGES
- psh
.nPages
);
132 SHAddFromPropSheetExtArray(hpsxa
, PropSheetAddPage
, (LPARAM
)&psh
);
134 ret
= (LONG
)(PropertySheet(&psh
) != -1);
137 SHDestroyPropSheetExtArray(hpsxa
);
142 /* Control Panel Callback */
144 CPlApplet(HWND hwndCPl
,
149 int i
= (int)lParam1
;
165 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
167 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
168 CPlInfo
->idName
= Applets
[i
].idName
;
169 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
175 Applets
[i
].AppletProc(hwndCPl
, uMsg
, lParam1
, lParam2
);
185 DllMain(HINSTANCE hinstDLL
,
189 UNREFERENCED_PARAMETER(lpvReserved
);
193 case DLL_PROCESS_ATTACH
:
194 case DLL_THREAD_ATTACH
: