Author: ekohl
Date: Sun Dec 2 17:25:17 2007
New Revision: 30957
URL:
http://svn.reactos.org/svn/reactos?rev=30957&view=rev
Log:
- Make local functions static.
- Reorder functions to reduce the number of required prototypes.
- Use Win32 types instead of generic types (e.g. int -> INT) and add missing VOIDs.
- No code changes.
Modified:
trunk/reactos/dll/cpl/powercfg/advanced.c
trunk/reactos/dll/cpl/powercfg/alarms.c
trunk/reactos/dll/cpl/powercfg/hibernate.c
trunk/reactos/dll/cpl/powercfg/powercfg.c
trunk/reactos/dll/cpl/powercfg/powercfg.h
trunk/reactos/dll/cpl/powercfg/powershemes.c
Modified: trunk/reactos/dll/cpl/powercfg/advanced.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/powercfg/advanced.…
==============================================================================
--- trunk/reactos/dll/cpl/powercfg/advanced.c (original)
+++ trunk/reactos/dll/cpl/powercfg/advanced.c Sun Dec 2 17:25:17 2007
@@ -22,66 +22,15 @@
#include "resource.h"
#include "powercfg.h"
-HWND hAdv=0;
-
-void Adv_InitDialog();
-void Adv_SaveData(HWND hwndDlg);
+HWND hAdv = 0;
static POWER_ACTION g_SystemBatteries[3];
static POWER_ACTION g_PowerButton[5];
static POWER_ACTION g_SleepButton[5];
-/* Property page dialog callback */
-INT_PTR CALLBACK
-advancedProc(
- HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
-{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- hAdv = hwndDlg;
- Adv_InitDialog();
- return TRUE;
- break;
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case IDC_SYSTRAYBATTERYMETER:
- case IDC_PASSWORDLOGON:
- case IDC_VIDEODIMDISPLAY:
- if (HIWORD(wParam) == BN_CLICKED)
- {
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
- }
- break;
- case IDC_LIDCLOSE:
- case IDC_POWERBUTTON:
- case IDC_SLEEPBUTTON:
- if (HIWORD(wParam) == CBN_SELCHANGE)
- {
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
- }
- break;
- }
- break;
- case WM_NOTIFY:
- {
- LPNMHDR lpnm = (LPNMHDR)lParam;
- if (lpnm->code == (UINT)PSN_APPLY)
- {
- Adv_SaveData(hwndDlg);
- }
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static void AddItem(HWND hDlgCtrl, int ResourceId, LPARAM lParam, POWER_ACTION *
lpAction)
+
+static VOID
+AddItem(HWND hDlgCtrl, INT ResourceId, LPARAM lParam, POWER_ACTION * lpAction)
{
TCHAR szBuffer[MAX_PATH];
LRESULT Index;
@@ -96,11 +45,12 @@
}
}
-static int FindActionIndex(POWER_ACTION * lpAction, DWORD dwActionSize, POWER_ACTION
poAction)
-{
- int Index;
-
- for (Index = 0; Index < (int) dwActionSize; Index++)
+static INT
+FindActionIndex(POWER_ACTION * lpAction, DWORD dwActionSize, POWER_ACTION poAction)
+{
+ INT Index;
+
+ for (Index = 0; Index < (INT)dwActionSize; Index++)
{
if (lpAction[Index] == poAction)
return Index;
@@ -109,7 +59,8 @@
return -1;
}
-static BOOLEAN IsBatteryUsed()
+static BOOLEAN
+IsBatteryUsed(VOID)
{
SYSTEM_BATTERY_STATE sbs;
@@ -128,7 +79,8 @@
return FALSE;
}
-POWER_ACTION GetPowerActionFromPolicy(POWER_ACTION_POLICY * Policy)
+POWER_ACTION
+GetPowerActionFromPolicy(POWER_ACTION_POLICY *Policy)
{
POWER_ACTION poAction = PowerActionNone;
/*
@@ -171,10 +123,11 @@
return poAction;
}
-void ShowCurrentPowerActionPolicy(HWND hDlgCtrl,
- POWER_ACTION * lpAction,
- DWORD dwActionSize,
- POWER_ACTION_POLICY * Policy)
+VOID
+ShowCurrentPowerActionPolicy(HWND hDlgCtrl,
+ POWER_ACTION *lpAction,
+ DWORD dwActionSize,
+ POWER_ACTION_POLICY *Policy)
{
int poActionIndex;
POWER_ACTION poAction;
@@ -190,8 +143,9 @@
SendMessage(hDlgCtrl, CB_SETCURSEL, (WPARAM)poActionIndex, (LPARAM)0);
}
-BOOLEAN SaveCurrentPowerActionPolicy(IN HWND hDlgCtrl,
- OUT POWER_ACTION_POLICY * Policy)
+BOOLEAN
+SaveCurrentPowerActionPolicy(IN HWND hDlgCtrl,
+ OUT POWER_ACTION_POLICY *Policy)
{
LRESULT Index;
LRESULT ItemData;
@@ -236,7 +190,8 @@
//-------------------------------------------------------------------
-void ShowCurrentPowerActionPolicies(HWND hwndDlg)
+VOID
+ShowCurrentPowerActionPolicies(HWND hwndDlg)
{
TCHAR szAction[MAX_PATH];
@@ -323,7 +278,8 @@
}
}
-void Adv_InitDialog()
+VOID
+Adv_InitDialog(VOID)
{
HWND hList1;
HWND hList2;
@@ -445,7 +401,8 @@
}
-void Adv_SaveData(HWND hwndDlg)
+static VOID
+Adv_SaveData(HWND hwndDlg)
{
BOOL bSystrayBatteryMeter;
BOOL bPasswordLogon;
@@ -529,3 +486,51 @@
Adv_InitDialog();
}
+
+/* Property page dialog callback */
+INT_PTR CALLBACK
+AdvancedDlgProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ hAdv = hwndDlg;
+ Adv_InitDialog();
+ return TRUE;
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDC_SYSTRAYBATTERYMETER:
+ case IDC_PASSWORDLOGON:
+ case IDC_VIDEODIMDISPLAY:
+ if (HIWORD(wParam) == BN_CLICKED)
+ {
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ }
+ break;
+ case IDC_LIDCLOSE:
+ case IDC_POWERBUTTON:
+ case IDC_SLEEPBUTTON:
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ }
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ {
+ LPNMHDR lpnm = (LPNMHDR)lParam;
+ if (lpnm->code == (UINT)PSN_APPLY)
+ {
+ Adv_SaveData(hwndDlg);
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
Modified: trunk/reactos/dll/cpl/powercfg/alarms.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/powercfg/alarms.c?…
==============================================================================
--- trunk/reactos/dll/cpl/powercfg/alarms.c (original)
+++ trunk/reactos/dll/cpl/powercfg/alarms.c Sun Dec 2 17:25:17 2007
@@ -20,35 +20,8 @@
#include "resource.h"
#include "powercfg.h"
-BOOLEAN Ala_InitData(HWND);
-
-/* Property page dialog callback */
-INT_PTR CALLBACK
-alarmsProc(
- HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
-{
- UNREFERENCED_PARAMETER(lParam);
- UNREFERENCED_PARAMETER(wParam);
- switch(uMsg)
- {
- case WM_INITDIALOG:
- if (!Ala_InitData(hwndDlg))
- {
- //TODO
- //handle initialization error
- }
- return TRUE;
- default:
- break;
- }
- return FALSE;
-}
-
-BOOLEAN Ala_InitData(HWND hwndDlg)
+static BOOLEAN
+Ala_InitData(HWND hwndDlg)
{
TCHAR szAction[MAX_PATH];
TCHAR szText[MAX_PATH];
@@ -197,3 +170,27 @@
return TRUE;
}
+
+/* Property page dialog callback */
+INT_PTR CALLBACK
+AlarmsDlgProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(lParam);
+ UNREFERENCED_PARAMETER(wParam);
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ if (!Ala_InitData(hwndDlg))
+ {
+ //TODO
+ //handle initialization error
+ }
+ return TRUE;
+ default:
+ break;
+ }
+ return FALSE;
+}
Modified: trunk/reactos/dll/cpl/powercfg/hibernate.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/powercfg/hibernate…
==============================================================================
--- trunk/reactos/dll/cpl/powercfg/hibernate.c (original)
+++ trunk/reactos/dll/cpl/powercfg/hibernate.c Sun Dec 2 17:25:17 2007
@@ -26,48 +26,12 @@
#include "powercfg.h"
-void Hib_InitDialog(HWND);
-INT_PTR Hib_SaveData(HWND);
BOOLEAN Pos_InitData();
void Adv_InitDialog();
-/* Property page dialog callback */
-INT_PTR CALLBACK
-hibernateProc(
- HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
-{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- Hib_InitDialog(hwndDlg);
- return TRUE;
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case IDC_HIBERNATEFILE:
- if (HIWORD(wParam) == BN_CLICKED)
- {
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
- }
- }
- break;
- case WM_NOTIFY:
- {
- LPNMHDR lpnm = (LPNMHDR)lParam;
- if (lpnm->code == (UINT)PSN_APPLY)
- {
- return Hib_SaveData(hwndDlg);
- }
- }
- }
- return FALSE;
-}
-void Hib_InitDialog(HWND hwndDlg)
+static VOID
+Hib_InitDialog(HWND hwndDlg)
{
SYSTEM_POWER_CAPABILITIES PowerCaps;
MEMORYSTATUSEX msex;
@@ -145,7 +109,8 @@
}
}
-INT_PTR Hib_SaveData(HWND hwndDlg)
+INT_PTR
+Hib_SaveData(HWND hwndDlg)
{
BOOLEAN bHibernate;
@@ -161,3 +126,37 @@
return FALSE;
}
+
+/* Property page dialog callback */
+INT_PTR CALLBACK
+HibernateDlgProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ Hib_InitDialog(hwndDlg);
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDC_HIBERNATEFILE:
+ if (HIWORD(wParam) == BN_CLICKED)
+ {
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ }
+ }
+ break;
+ case WM_NOTIFY:
+ {
+ LPNMHDR lpnm = (LPNMHDR)lParam;
+ if (lpnm->code == (UINT)PSN_APPLY)
+ {
+ return Hib_SaveData(hwndDlg);
+ }
+ }
+ }
+ return FALSE;
+}
Modified: trunk/reactos/dll/cpl/powercfg/powercfg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/powercfg/powercfg.…
==============================================================================
--- trunk/reactos/dll/cpl/powercfg/powercfg.c (original)
+++ trunk/reactos/dll/cpl/powercfg/powercfg.c Sun Dec 2 17:25:17 2007
@@ -22,10 +22,7 @@
#define NUM_APPLETS (1)
static LONG APIENTRY Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK powershemesProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK alarmsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK advancedProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK hibernateProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
HINSTANCE hApplet = 0;
GLOBAL_POWER_POLICY gGPP;
@@ -76,39 +73,6 @@
}
-/* Property Sheet Callback */
-int CALLBACK
-PropSheetProc(
- HWND hwndDlg,
- UINT uMsg,
- LPARAM lParam
-)
-{
- UNREFERENCED_PARAMETER(hwndDlg);
- switch(uMsg)
- {
- case PSCB_BUTTONPRESSED:
- switch(lParam)
- {
- case PSBTN_OK: /* OK */
- break;
- case PSBTN_CANCEL: /* Cancel */
- break;
- case PSBTN_APPLYNOW: /* Apply now */
- break;
- case PSBTN_FINISH: /* Close */
- break;
- default:
- return FALSE;
- }
- break;
-
- case PSCB_INITIALIZED:
- break;
- }
- return TRUE;
-}
-
/* First Applet */
static LONG APIENTRY
Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
@@ -130,7 +94,7 @@
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
- psh.dwFlags = PSH_USECALLBACK | PSH_PROPTITLE;
+ psh.dwFlags = PSH_PROPTITLE;
psh.hwndParent = NULL;
psh.hInstance = hApplet;
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON_1));
@@ -138,18 +102,17 @@
psh.nPages = 0;
psh.nStartPage = 0;
psh.phpage = hpsp;
- psh.pfnCallback = PropSheetProc;
- InitPropSheetPage(&psh, IDD_PROPPAGEPOWERSHEMES, (DLGPROC) powershemesProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGEPOWERSHEMES, (DLGPROC)PowerSchemesDlgProc);
if (GetPwrCapabilities(&spc))
{
if (spc.SystemBatteriesPresent)
{
- InitPropSheetPage(&psh, IDD_PROPPAGEALARMS, (DLGPROC) alarmsProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGEALARMS, (DLGPROC)AlarmsDlgProc);
}
}
- InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, (DLGPROC) advancedProc);
- InitPropSheetPage(&psh, IDD_PROPPAGEHIBERNATE, (DLGPROC) hibernateProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, (DLGPROC)AdvancedDlgProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGEHIBERNATE, (DLGPROC)HibernateDlgProc);
/* Load additional pages provided by shell extensions */
hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER
TEXT("\\Power"), MAX_POWER_PAGES - psh.nPages);
@@ -166,11 +129,10 @@
/* Control Panel Callback */
LONG CALLBACK
-CPlApplet(
- HWND hwndCPl,
- UINT uMsg,
- LPARAM lParam1,
- LPARAM lParam2)
+CPlApplet(HWND hwndCPl,
+ UINT uMsg,
+ LPARAM lParam1,
+ LPARAM lParam2)
{
int i = (int)lParam1;
@@ -203,12 +165,10 @@
}
-BOOLEAN
-WINAPI
-DllMain(
- HINSTANCE hinstDLL,
- DWORD dwReason,
- LPVOID lpvReserved)
+BOOLEAN WINAPI
+DllMain(HINSTANCE hinstDLL,
+ DWORD dwReason,
+ LPVOID lpvReserved)
{
UNREFERENCED_PARAMETER(lpvReserved);
switch(dwReason)
Modified: trunk/reactos/dll/cpl/powercfg/powercfg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/powercfg/powercfg.…
==============================================================================
--- trunk/reactos/dll/cpl/powercfg/powercfg.h (original)
+++ trunk/reactos/dll/cpl/powercfg/powercfg.h Sun Dec 2 17:25:17 2007
@@ -18,6 +18,11 @@
#define MAX_POWER_PAGES 32
+INT_PTR CALLBACK PowerSchemesDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam);
+INT_PTR CALLBACK AlarmsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK AdvancedDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK HibernateDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam);
+
#endif /* __CPL_SAMPLE_H */
/* EOF */
Modified: trunk/reactos/dll/cpl/powercfg/powershemes.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/powercfg/powershem…
==============================================================================
--- trunk/reactos/dll/cpl/powercfg/powershemes.c (original)
+++ trunk/reactos/dll/cpl/powercfg/powershemes.c Sun Dec 2 17:25:17 2007
@@ -49,132 +49,9 @@
UINT guiIndex = 0;
HWND hwndDialog;
-void LoadConfig(HWND hwndDlg);
-void Pos_InitPage(HWND hwndDlg);
-BOOLEAN Pos_InitData();
-void Pos_SaveData(HWND hwndDlg);
-
-
-BOOLEAN CreateEnergyList(HWND hwnd);
-
-static
-BOOLEAN DelScheme(HWND hwnd)
-{
- INT iCurSel;
- HWND hList;
- TCHAR szBuf[1024], szBufT[1024];
- UINT DelScheme;
-
- hList = GetDlgItem(hwnd, IDC_ENERGYLIST);
-
- iCurSel = SendMessage(hList, CB_GETCURSEL, 0, 0);
- if (iCurSel == CB_ERR) return FALSE;
-
- SendMessage(hList, CB_SETCURSEL, iCurSel, 0);
-
- DelScheme = SendMessage(hList, CB_GETITEMDATA, (WPARAM)iCurSel, 0);
- if (DelScheme == (UINT)CB_ERR) return FALSE;
-
- LoadString(hApplet, IDS_DEL_SCHEME_TITLE, szBufT, sizeof(szBufT) / sizeof(TCHAR));
- LoadString(hApplet, IDS_DEL_SCHEME, szBuf, sizeof(szBuf) / sizeof(TCHAR));
-
- if (MessageBox(hwnd, (LPCTSTR)szBuf, (LPCTSTR)szBufT, MB_OKCANCEL | MB_ICONQUESTION) ==
IDOK)
- {
- UINT Current;
-
- if (GetActivePwrScheme(&Current))
- {
- SendMessage(hList, CB_SETCURSEL, (WPARAM)0, 0);
- SendMessage(hList, CB_DELETESTRING, (WPARAM)iCurSel, 0);
- if (Current == DelScheme) Pos_SaveData(hwnd);
- }
-
- if (DeletePwrScheme(DelScheme) != 0) return TRUE;
- }
-
- return FALSE;
-}
-
-/* Property page dialog callback */
-INT_PTR CALLBACK
-powershemesProc(
- HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
-{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- hPos = hwndDlg;
- hwndDialog = hwndDlg;
- if (!Pos_InitData())
- {
- //TODO
- // initialization failed
- // handle error
- MessageBox(hwndDlg,_T("Pos_InitData failed\n"), NULL, MB_OK);
-
- }
- if (!CreateEnergyList(GetDlgItem(hwndDlg, IDC_ENERGYLIST)))
- {
- //TODO
- // initialization failed
- // handle error
- MessageBox(hwndDlg,_T("CreateEnergyList failed\n"), NULL, MB_OK);
- }
- return TRUE;
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case IDC_ENERGYLIST:
- if (HIWORD(wParam) == CBN_SELCHANGE)
- {
- LoadConfig(hwndDlg);
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
- }
- break;
- case IDC_DELETE_BTN:
- {
- DelScheme(hwndDlg);
- }
- break;
- case IDC_SAVEAS_BTN:
- {
-
- }
- break;
- case IDC_MONITORACLIST:
- case IDC_MONITORDCLIST:
- case IDC_DISKACLIST:
- case IDC_DISKDCLIST:
- case IDC_STANDBYACLIST:
- case IDC_STANDBYDCLIST:
- case IDC_HYBERNATEACLIST:
- case IDC_HYBERNATEDCLIST:
- if (HIWORD(wParam) == CBN_SELCHANGE)
- {
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
- }
- break;
- }
- break;
- case WM_NOTIFY:
- {
- LPNMHDR lpnm = (LPNMHDR)lParam;
- if (lpnm->code == (UINT)PSN_APPLY)
- {
- Pos_SaveData(hwndDlg);
- }
- return TRUE;
- }
- break;
- }
- return FALSE;
-}
-
-BOOLEAN Pos_InitData()
+
+BOOLEAN
+Pos_InitData(VOID)
{
SYSTEM_POWER_CAPABILITIES spc;
/*
@@ -271,8 +148,104 @@
return TRUE;
}
-BOOLEAN CALLBACK callback_EnumPwrScheme(UINT uiIndex, DWORD dwName, LPTSTR sName, DWORD
dwDesc,
- LPWSTR sDesc, PPOWER_POLICY pp,LPARAM lParam
)
+
+static VOID
+LoadConfig(HWND hwndDlg)
+{
+ INT i=0, iCurSel=0;
+ UINT uiIndex;
+ TCHAR szProfile[MAX_PATH];
+ TCHAR szTemp[MAX_PATH];
+ TCHAR szConfig[MAX_PATH];
+ POWER_POLICY pp;
+
+ iCurSel = (INT)SendDlgItemMessage(hwndDlg, IDC_ENERGYLIST,
+ CB_GETCURSEL,
+ 0,
+ 0);
+ if (iCurSel == CB_ERR)
+ return;
+
+ memcpy(&pp, &gPP[iCurSel], sizeof(POWER_POLICY));
+
+ uiIndex = (UINT)SendDlgItemMessage(hwndDlg, IDC_ENERGYLIST, CB_GETCURSEL, 0, 0);
+ if(uiIndex != CB_ERR)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_ENERGYLIST, CB_GETLBTEXT, uiIndex, (LPARAM)szProfile);
+ if(LoadString(hApplet, IDS_CONFIG1, szTemp, MAX_PATH))
+ {
+ _stprintf(szConfig,szTemp,szProfile);
+ SetWindowText(GetDlgItem(hwndDlg, IDC_GRPDETAIL),szConfig);
+ }
+ }
+
+ for(i=0;i<17;i++)
+ {
+ if (Sec[i]==pp.user.VideoTimeoutAc)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_MONITORACLIST,
+ CB_SETCURSEL,
+ i,
+ (LPARAM)0);
+ }
+
+ if (Sec[i]==pp.user.VideoTimeoutDc)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_MONITORDCLIST,
+ CB_SETCURSEL,
+ i,
+ (LPARAM)0);
+ }
+ if (Sec[i]==pp.user.SpindownTimeoutAc)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_DISKACLIST,
+ CB_SETCURSEL,
+ i-2,
+ (LPARAM)0);
+ }
+ if (Sec[i]==pp.user.SpindownTimeoutDc)//IdleTimeoutDc)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_DISKDCLIST,
+ CB_SETCURSEL,
+ i-2,
+ (LPARAM)0);
+ }
+ if (Sec[i]==pp.user.IdleTimeoutAc)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_STANDBYACLIST,
+ CB_SETCURSEL,
+ i,
+ (LPARAM)0);
+ }
+ if (Sec[i]==pp.user.IdleTimeoutDc)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_STANDBYDCLIST,
+ CB_SETCURSEL,
+ i,
+ (LPARAM)0);
+ }
+
+ if (Sec[i]==pp.mach.DozeS4TimeoutAc)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_HYBERNATEACLIST,
+ CB_SETCURSEL,
+ i,
+ (LPARAM)0);
+ }
+ if (Sec[i]==pp.mach.DozeS4TimeoutDc)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_HYBERNATEDCLIST,
+ CB_SETCURSEL,
+ i,
+ (LPARAM)0);
+ }
+ }
+}
+
+
+BOOLEAN CALLBACK
+callback_EnumPwrScheme(UINT uiIndex, DWORD dwName, LPTSTR sName, DWORD dwDesc,
+ LPWSTR sDesc, PPOWER_POLICY pp,LPARAM lParam)
{
int index;
@@ -318,7 +291,213 @@
return TRUE;
}
-BOOLEAN CreateEnergyList(HWND hwnd)
+
+static VOID
+Pos_InitPage(HWND hwndDlg)
+{
+ int ifrom=0,i=0,imin=0;
+ HWND hwnd = NULL;
+ TCHAR szName[MAX_PATH];
+ LRESULT index;
+
+ for(i=1;i<9;i++)
+ {
+ switch(i)
+ {
+ case 1:
+ hwnd=GetDlgItem(hwndDlg, IDC_MONITORACLIST);
+ imin=IDS_TIMEOUT1;
+ break;
+ case 2:
+ hwnd=GetDlgItem(hwndDlg, IDC_STANDBYACLIST);
+ imin=IDS_TIMEOUT1;
+ break;
+ case 3:
+ hwnd=GetDlgItem(hwndDlg, IDC_DISKACLIST);
+ imin=IDS_TIMEOUT3;
+ break;
+ case 4:
+ hwnd=GetDlgItem(hwndDlg, IDC_HYBERNATEACLIST);
+ imin=IDS_TIMEOUT3;
+ break;
+ case 5:
+ hwnd=GetDlgItem(hwndDlg, IDC_MONITORDCLIST);
+ imin=IDS_TIMEOUT1;
+ break;
+ case 6:
+ hwnd=GetDlgItem(hwndDlg, IDC_STANDBYDCLIST);
+ imin=IDS_TIMEOUT1;
+ break;
+ case 7:
+ hwnd=GetDlgItem(hwndDlg, IDC_DISKDCLIST);
+ imin=IDS_TIMEOUT3;
+ break;
+ case 8:
+ hwnd=GetDlgItem(hwndDlg, IDC_HYBERNATEDCLIST);
+ imin=IDS_TIMEOUT3;
+ break;
+ default:
+ return;
+ }
+ for (ifrom=imin;ifrom<(IDS_TIMEOUT15+1);ifrom++)
+ {
+ if (LoadString(hApplet, ifrom, szName, MAX_PATH))
+ {
+ index = SendMessage(hwnd,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)szName);
+
+ if (index == CB_ERR)
+ return;
+
+ SendMessage(hwnd,
+ CB_SETITEMDATA,
+ index,
+ (LPARAM)Sec[ifrom-IDS_TIMEOUT16]);
+ }
+ }
+ if (LoadString(hApplet, IDS_TIMEOUT16, szName, MAX_PATH))
+ {
+ index = SendMessage(hwnd,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)szName);
+ if (index == CB_ERR)
+ return;
+
+ SendMessage(hwnd,
+ CB_SETITEMDATA,
+ index,
+ (LPARAM)Sec[0]);
+ }
+ }
+}
+
+
+static VOID
+Pos_SaveData(HWND hwndDlg)
+{
+ INT iCurSel=0,tmp=0;
+
+ iCurSel = (INT) SendDlgItemMessage(hwndDlg, IDC_ENERGYLIST,
+ CB_GETCURSEL,
+ 0,
+ 0);
+ if (iCurSel == CB_ERR)
+ return;
+
+ tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_MONITORDCLIST,
+ CB_GETCURSEL,
+ 0,
+ (LPARAM)0);
+ if (tmp > 0 && tmp < 16)
+ {
+ gPP[iCurSel].user.VideoTimeoutAc = Sec[tmp];
+ }
+ tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_MONITORDCLIST,
+ CB_GETCURSEL,
+ 0,
+ (LPARAM)0);
+ if (tmp > 0 && tmp < 16)
+ {
+ gPP[iCurSel].user.VideoTimeoutDc = Sec[tmp];
+ }
+ tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_DISKACLIST,
+ CB_GETCURSEL,
+ 0,
+ (LPARAM)0);
+ if (tmp > 0 && tmp < 16)
+ {
+ gPP[iCurSel].user.SpindownTimeoutAc = Sec[tmp+2];
+ }
+ tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_DISKDCLIST,
+ CB_GETCURSEL,
+ 0,
+ (LPARAM)0);
+ if (tmp > 0 && tmp < 16)
+ {
+ gPP[iCurSel].user.SpindownTimeoutDc = Sec[tmp+2];
+ }
+ tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_STANDBYACLIST,
+ CB_GETCURSEL,
+ 0,
+ (LPARAM)0);
+ if (tmp > 0 && tmp < 16)
+ {
+ gPP[iCurSel].user.IdleTimeoutAc = Sec[tmp];
+ }
+ tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_STANDBYDCLIST,
+ CB_GETCURSEL,
+ 0,
+ (LPARAM)0);
+ if (tmp > 0 && tmp < 16)
+ {
+ gPP[iCurSel].user.IdleTimeoutDc = Sec[tmp];
+ }
+ tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_HYBERNATEACLIST,
+ CB_GETCURSEL,
+ 0,
+ (LPARAM)0);
+ if (tmp > 0 && tmp < 16)
+ {
+ gPP[iCurSel].mach.DozeS4TimeoutAc = Sec[tmp];
+ }
+ tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_HYBERNATEDCLIST,
+ CB_GETCURSEL,
+ 0,
+ (LPARAM)0);
+ if (tmp > 0 && tmp < 16)
+ {
+ gPP[iCurSel].mach.DozeS4TimeoutDc = Sec[tmp];
+ }
+
+ SetActivePwrScheme(iCurSel,NULL,&gPP[iCurSel]);
+ LoadConfig(hwndDlg);
+}
+
+
+static BOOLEAN
+DelScheme(HWND hwnd)
+{
+ INT iCurSel;
+ HWND hList;
+ TCHAR szBuf[1024], szBufT[1024];
+ UINT DelScheme;
+
+ hList = GetDlgItem(hwnd, IDC_ENERGYLIST);
+
+ iCurSel = SendMessage(hList, CB_GETCURSEL, 0, 0);
+ if (iCurSel == CB_ERR) return FALSE;
+
+ SendMessage(hList, CB_SETCURSEL, iCurSel, 0);
+
+ DelScheme = SendMessage(hList, CB_GETITEMDATA, (WPARAM)iCurSel, 0);
+ if (DelScheme == (UINT)CB_ERR) return FALSE;
+
+ LoadString(hApplet, IDS_DEL_SCHEME_TITLE, szBufT, sizeof(szBufT) / sizeof(TCHAR));
+ LoadString(hApplet, IDS_DEL_SCHEME, szBuf, sizeof(szBuf) / sizeof(TCHAR));
+
+ if (MessageBox(hwnd, (LPCTSTR)szBuf, (LPCTSTR)szBufT, MB_OKCANCEL | MB_ICONQUESTION) ==
IDOK)
+ {
+ UINT Current;
+
+ if (GetActivePwrScheme(&Current))
+ {
+ SendMessage(hList, CB_SETCURSEL, (WPARAM)0, 0);
+ SendMessage(hList, CB_DELETESTRING, (WPARAM)iCurSel, 0);
+ if (Current == DelScheme) Pos_SaveData(hwnd);
+ }
+
+ if (DeletePwrScheme(DelScheme) != 0) return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+static BOOLEAN
+CreateEnergyList(HWND hwnd)
{
BOOLEAN retval;
POWER_POLICY pp;
@@ -368,256 +547,82 @@
return retval;
}
-void Pos_InitPage(HWND hwndDlg)
-{
- int ifrom=0,i=0,imin=0;
- HWND hwnd = NULL;
- TCHAR szName[MAX_PATH];
- LRESULT index;
-
- for(i=1;i<9;i++)
- {
- switch(i)
- {
- case 1:
- hwnd=GetDlgItem(hwndDlg, IDC_MONITORACLIST);
- imin=IDS_TIMEOUT1;
- break;
- case 2:
- hwnd=GetDlgItem(hwndDlg, IDC_STANDBYACLIST);
- imin=IDS_TIMEOUT1;
- break;
- case 3:
- hwnd=GetDlgItem(hwndDlg, IDC_DISKACLIST);
- imin=IDS_TIMEOUT3;
- break;
- case 4:
- hwnd=GetDlgItem(hwndDlg, IDC_HYBERNATEACLIST);
- imin=IDS_TIMEOUT3;
- break;
- case 5:
- hwnd=GetDlgItem(hwndDlg, IDC_MONITORDCLIST);
- imin=IDS_TIMEOUT1;
- break;
- case 6:
- hwnd=GetDlgItem(hwndDlg, IDC_STANDBYDCLIST);
- imin=IDS_TIMEOUT1;
- break;
- case 7:
- hwnd=GetDlgItem(hwndDlg, IDC_DISKDCLIST);
- imin=IDS_TIMEOUT3;
- break;
- case 8:
- hwnd=GetDlgItem(hwndDlg, IDC_HYBERNATEDCLIST);
- imin=IDS_TIMEOUT3;
- break;
- default:
- return;
- }
- for (ifrom=imin;ifrom<(IDS_TIMEOUT15+1);ifrom++)
- {
- if (LoadString(hApplet, ifrom, szName, MAX_PATH))
+
+/* Property page dialog callback */
+INT_PTR CALLBACK
+PowerSchemesDlgProc(
+ HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+)
+{
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ hPos = hwndDlg;
+ hwndDialog = hwndDlg;
+ if (!Pos_InitData())
+ {
+ //TODO
+ // initialization failed
+ // handle error
+ MessageBox(hwndDlg,_T("Pos_InitData failed\n"), NULL, MB_OK);
+
+ }
+ if (!CreateEnergyList(GetDlgItem(hwndDlg, IDC_ENERGYLIST)))
+ {
+ //TODO
+ // initialization failed
+ // handle error
+ MessageBox(hwndDlg,_T("CreateEnergyList failed\n"), NULL, MB_OK);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDC_ENERGYLIST:
+ if (HIWORD(wParam) == CBN_SELCHANGE)
{
- index = SendMessage(hwnd,
- CB_ADDSTRING,
- 0,
- (LPARAM)szName);
-
- if (index == CB_ERR)
- return;
-
- SendMessage(hwnd,
- CB_SETITEMDATA,
- index,
- (LPARAM)Sec[ifrom-IDS_TIMEOUT16]);
+ LoadConfig(hwndDlg);
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
- }
- if (LoadString(hApplet, IDS_TIMEOUT16, szName, MAX_PATH))
- {
- index = SendMessage(hwnd,
- CB_ADDSTRING,
- 0,
- (LPARAM)szName);
- if (index == CB_ERR)
- return;
-
- SendMessage(hwnd,
- CB_SETITEMDATA,
- index,
- (LPARAM)Sec[0]);
- }
- }
-}
-
-void LoadConfig(HWND hwndDlg)
-{
- INT i=0, iCurSel=0;
- UINT uiIndex;
- TCHAR szProfile[MAX_PATH];
- TCHAR szTemp[MAX_PATH];
- TCHAR szConfig[MAX_PATH];
- POWER_POLICY pp;
-
- iCurSel = (INT)SendDlgItemMessage(hwndDlg, IDC_ENERGYLIST,
- CB_GETCURSEL,
- 0,
- 0);
- if (iCurSel == CB_ERR)
- return;
-
- memcpy(&pp, &gPP[iCurSel], sizeof(POWER_POLICY));
-
- uiIndex = (UINT)SendDlgItemMessage(hwndDlg, IDC_ENERGYLIST, CB_GETCURSEL, 0, 0);
- if(uiIndex != CB_ERR)
- {
- SendDlgItemMessage(hwndDlg, IDC_ENERGYLIST, CB_GETLBTEXT, uiIndex, (LPARAM)szProfile);
- if(LoadString(hApplet, IDS_CONFIG1, szTemp, MAX_PATH))
- {
- _stprintf(szConfig,szTemp,szProfile);
- SetWindowText(GetDlgItem(hwndDlg, IDC_GRPDETAIL),szConfig);
- }
- }
-
- for(i=0;i<17;i++)
- {
- if (Sec[i]==pp.user.VideoTimeoutAc)
- {
- SendDlgItemMessage(hwndDlg, IDC_MONITORACLIST,
- CB_SETCURSEL,
- i,
- (LPARAM)0);
- }
-
- if (Sec[i]==pp.user.VideoTimeoutDc)
- {
- SendDlgItemMessage(hwndDlg, IDC_MONITORDCLIST,
- CB_SETCURSEL,
- i,
- (LPARAM)0);
- }
- if (Sec[i]==pp.user.SpindownTimeoutAc)
- {
- SendDlgItemMessage(hwndDlg, IDC_DISKACLIST,
- CB_SETCURSEL,
- i-2,
- (LPARAM)0);
- }
- if (Sec[i]==pp.user.SpindownTimeoutDc)//IdleTimeoutDc)
- {
- SendDlgItemMessage(hwndDlg, IDC_DISKDCLIST,
- CB_SETCURSEL,
- i-2,
- (LPARAM)0);
- }
- if (Sec[i]==pp.user.IdleTimeoutAc)
- {
- SendDlgItemMessage(hwndDlg, IDC_STANDBYACLIST,
- CB_SETCURSEL,
- i,
- (LPARAM)0);
- }
- if (Sec[i]==pp.user.IdleTimeoutDc)
- {
- SendDlgItemMessage(hwndDlg, IDC_STANDBYDCLIST,
- CB_SETCURSEL,
- i,
- (LPARAM)0);
- }
-
- if (Sec[i]==pp.mach.DozeS4TimeoutAc)
- {
- SendDlgItemMessage(hwndDlg, IDC_HYBERNATEACLIST,
- CB_SETCURSEL,
- i,
- (LPARAM)0);
- }
- if (Sec[i]==pp.mach.DozeS4TimeoutDc)
- {
- SendDlgItemMessage(hwndDlg, IDC_HYBERNATEDCLIST,
- CB_SETCURSEL,
- i,
- (LPARAM)0);
- }
- }
-
-}
-
-void Pos_SaveData(HWND hwndDlg)
-{
- INT iCurSel=0,tmp=0;
-
- iCurSel = (INT) SendDlgItemMessage(hwndDlg, IDC_ENERGYLIST,
- CB_GETCURSEL,
- 0,
- 0);
- if (iCurSel == CB_ERR)
- return;
-
- tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_MONITORDCLIST,
- CB_GETCURSEL,
- 0,
- (LPARAM)0);
- if (tmp > 0 && tmp < 16)
- {
- gPP[iCurSel].user.VideoTimeoutAc = Sec[tmp];
- }
- tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_MONITORDCLIST,
- CB_GETCURSEL,
- 0,
- (LPARAM)0);
- if (tmp > 0 && tmp < 16)
- {
- gPP[iCurSel].user.VideoTimeoutDc = Sec[tmp];
- }
- tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_DISKACLIST,
- CB_GETCURSEL,
- 0,
- (LPARAM)0);
- if (tmp > 0 && tmp < 16)
- {
- gPP[iCurSel].user.SpindownTimeoutAc = Sec[tmp+2];
- }
- tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_DISKDCLIST,
- CB_GETCURSEL,
- 0,
- (LPARAM)0);
- if (tmp > 0 && tmp < 16)
- {
- gPP[iCurSel].user.SpindownTimeoutDc = Sec[tmp+2];
- }
- tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_STANDBYACLIST,
- CB_GETCURSEL,
- 0,
- (LPARAM)0);
- if (tmp > 0 && tmp < 16)
- {
- gPP[iCurSel].user.IdleTimeoutAc = Sec[tmp];
- }
- tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_STANDBYDCLIST,
- CB_GETCURSEL,
- 0,
- (LPARAM)0);
- if (tmp > 0 && tmp < 16)
- {
- gPP[iCurSel].user.IdleTimeoutDc = Sec[tmp];
- }
- tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_HYBERNATEACLIST,
- CB_GETCURSEL,
- 0,
- (LPARAM)0);
- if (tmp > 0 && tmp < 16)
- {
- gPP[iCurSel].mach.DozeS4TimeoutAc = Sec[tmp];
- }
- tmp = (INT) SendDlgItemMessage(hwndDlg, IDC_HYBERNATEDCLIST,
- CB_GETCURSEL,
- 0,
- (LPARAM)0);
- if (tmp > 0 && tmp < 16)
- {
- gPP[iCurSel].mach.DozeS4TimeoutDc = Sec[tmp];
- }
-
- SetActivePwrScheme(iCurSel,NULL,&gPP[iCurSel]);
- LoadConfig(hwndDlg);
-}
+ break;
+ case IDC_DELETE_BTN:
+ {
+ DelScheme(hwndDlg);
+ }
+ break;
+ case IDC_SAVEAS_BTN:
+ {
+
+ }
+ break;
+ case IDC_MONITORACLIST:
+ case IDC_MONITORDCLIST:
+ case IDC_DISKACLIST:
+ case IDC_DISKDCLIST:
+ case IDC_STANDBYACLIST:
+ case IDC_STANDBYDCLIST:
+ case IDC_HYBERNATEACLIST:
+ case IDC_HYBERNATEDCLIST:
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ }
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ {
+ LPNMHDR lpnm = (LPNMHDR)lParam;
+ if (lpnm->code == (UINT)PSN_APPLY)
+ {
+ Pos_SaveData(hwndDlg);
+ }
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}