Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpowercfg.c
Go to the documentation of this file.
00001 /* $Id: powercfg.c 54535 2011-11-29 14:55:58Z dgorbachev $ 00002 * 00003 * PROJECT: ReactOS Power Configuration Applet 00004 * LICENSE: GPL - See COPYING in the top level directory 00005 * FILE: dll/cpl/powercfg/powershemes.c 00006 * PURPOSE: initialization of applet 00007 * PROGRAMMERS: Alexander Wurzinger (Lohnegrim at gmx dot net) 00008 * Johannes Anderwald (johannes.anderwald@student.tugraz.at) 00009 * Martin Rottensteiner 00010 * Dmitry Chapyshev (lentind@yandex.ru) 00011 */ 00012 00013 #include "powercfg.h" 00014 00015 #define NUM_APPLETS (1) 00016 00017 static LONG APIENTRY Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam); 00018 00019 00020 HINSTANCE hApplet = 0; 00021 GLOBAL_POWER_POLICY gGPP; 00022 TCHAR langSel[255]; 00023 00024 /* Applets */ 00025 APPLET Applets[NUM_APPLETS] = 00026 { 00027 {IDC_CPLICON_1, IDS_CPLNAME_1, IDS_CPLDESCRIPTION_1, Applet1} 00028 }; 00029 00030 static BOOL CALLBACK 00031 PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam) 00032 { 00033 PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam; 00034 if (ppsh != NULL && ppsh->nPages < MAX_POWER_PAGES) 00035 { 00036 ppsh->phpage[ppsh->nPages++] = hpage; 00037 return TRUE; 00038 } 00039 00040 return FALSE; 00041 } 00042 00043 static BOOL 00044 InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc) 00045 { 00046 HPROPSHEETPAGE hPage; 00047 PROPSHEETPAGE psp; 00048 00049 if (ppsh->nPages < MAX_POWER_PAGES) 00050 { 00051 ZeroMemory(&psp, sizeof(psp)); 00052 psp.dwSize = sizeof(psp); 00053 psp.dwFlags = PSP_DEFAULT; 00054 psp.hInstance = hApplet; 00055 psp.pszTemplate = MAKEINTRESOURCE(idDlg); 00056 psp.pfnDlgProc = DlgProc; 00057 00058 hPage = CreatePropertySheetPage(&psp); 00059 if (hPage != NULL) 00060 { 00061 return PropSheetAddPage(hPage, (LPARAM)ppsh); 00062 } 00063 } 00064 00065 return FALSE; 00066 } 00067 00068 00069 /* First Applet */ 00070 static LONG APIENTRY 00071 Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam) 00072 { 00073 HPROPSHEETPAGE hpsp[MAX_POWER_PAGES]; 00074 PROPSHEETHEADER psh; 00075 HPSXA hpsxa = NULL; 00076 TCHAR Caption[1024]; 00077 SYSTEM_POWER_CAPABILITIES spc; 00078 LONG ret; 00079 00080 UNREFERENCED_PARAMETER(uMsg); 00081 UNREFERENCED_PARAMETER(wParam); 00082 UNREFERENCED_PARAMETER(lParam); 00083 00084 memset(Caption, 0x0, sizeof(Caption)); 00085 LoadString(hApplet, IDS_CPLNAME_1, Caption, sizeof(Caption) / sizeof(TCHAR)); 00086 00087 ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); 00088 psh.dwSize = sizeof(PROPSHEETHEADER); 00089 psh.dwFlags = PSH_PROPTITLE; 00090 psh.hwndParent = hwnd; 00091 psh.hInstance = hApplet; 00092 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON_1)); 00093 psh.pszCaption = Caption; 00094 psh.nPages = 0; 00095 psh.nStartPage = 0; 00096 psh.phpage = hpsp; 00097 00098 InitPropSheetPage(&psh, IDD_PROPPAGEPOWERSHEMES, (DLGPROC)PowerSchemesDlgProc); 00099 if (GetPwrCapabilities(&spc)) 00100 { 00101 if (spc.SystemBatteriesPresent) 00102 { 00103 InitPropSheetPage(&psh, IDD_PROPPAGEALARMS, (DLGPROC)AlarmsDlgProc); 00104 } 00105 } 00106 InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, (DLGPROC)AdvancedDlgProc); 00107 InitPropSheetPage(&psh, IDD_PROPPAGEHIBERNATE, (DLGPROC)HibernateDlgProc); 00108 00109 /* Load additional pages provided by shell extensions */ 00110 hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Power"), MAX_POWER_PAGES - psh.nPages); 00111 if (hpsxa != NULL) 00112 SHAddFromPropSheetExtArray(hpsxa, PropSheetAddPage, (LPARAM)&psh); 00113 00114 ret = (LONG)(PropertySheet(&psh) != -1); 00115 00116 if (hpsxa != NULL) 00117 SHDestroyPropSheetExtArray(hpsxa); 00118 00119 return ret; 00120 } 00121 00122 /* Control Panel Callback */ 00123 LONG CALLBACK 00124 CPlApplet(HWND hwndCPl, 00125 UINT uMsg, 00126 LPARAM lParam1, 00127 LPARAM lParam2) 00128 { 00129 int i = (int)lParam1; 00130 00131 switch(uMsg) 00132 { 00133 case CPL_INIT: 00134 { 00135 return TRUE; 00136 } 00137 case CPL_GETCOUNT: 00138 { 00139 return NUM_APPLETS; 00140 } 00141 case CPL_INQUIRE: 00142 { 00143 CPLINFO *CPlInfo = (CPLINFO*)lParam2; 00144 CPlInfo->lData = 0; 00145 CPlInfo->idIcon = Applets[i].idIcon; 00146 CPlInfo->idName = Applets[i].idName; 00147 CPlInfo->idInfo = Applets[i].idDescription; 00148 break; 00149 } 00150 case CPL_DBLCLK: 00151 { 00152 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2); 00153 break; 00154 } 00155 } 00156 return FALSE; 00157 } 00158 00159 00160 BOOLEAN WINAPI 00161 DllMain(HINSTANCE hinstDLL, 00162 DWORD dwReason, 00163 LPVOID lpvReserved) 00164 { 00165 UNREFERENCED_PARAMETER(lpvReserved); 00166 switch(dwReason) 00167 { 00168 case DLL_PROCESS_ATTACH: 00169 case DLL_THREAD_ATTACH: 00170 hApplet = hinstDLL; 00171 break; 00172 } 00173 return TRUE; 00174 } Generated on Sat May 26 2012 04:19:46 for ReactOS by
1.7.6.1
|