ReactOS  0.4.13-dev-544-gede3fdd
alarms.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Power Configuration Applet
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/cpl/powercfg/alarms.c
5  * PURPOSE: alarms tab of applet
6  * PROGRAMMERS: Alexander Wurzinger (Lohnegrim at gmx dot net)
7  * Johannes Anderwald (johannes.anderwald@reactos.org)
8  * Martin Rottensteiner
9  * Dmitry Chapyshev (lentind@yandex.ru)
10  */
11 
12 #include "powercfg.h"
13 
14 static BOOLEAN
16 {
17  TCHAR szAction[MAX_PATH];
19  TCHAR szSound[MAX_PATH];
20  TCHAR szMessage[MAX_PATH];
21  TCHAR szTemp[MAX_PATH];
22  TCHAR szBatteryLevel[MAX_PATH];
23  TCHAR szProgram[MAX_PATH];
24 
26  {
27  return FALSE;
28  }
29 
31  {
32  CheckDlgButton(hwndDlg, IDC_ALARM1,
34 
35  if (LoadString(hApplet, IDS_PERCENT, szTemp, MAX_PATH))
36  {
38  SetDlgItemText(hwndDlg, IDC_ALARMVALUE1, szBatteryLevel);
39  }
40 
43  (WPARAM)TRUE,
44  (LPARAM)MAKELONG(0, 100));
47  (WPARAM)TRUE,
48  (LPARAM)20);
50  TBM_SETPOS,
51  (WPARAM)TRUE,
53 
55  {
56  SetDlgItemText(hwndDlg, IDC_ALARMAKTION1, szAction);
57  }
58 
59  memset(szMessage, 0x0, sizeof(szMessage));
61 
63  {
65  {
67  {
68  _stprintf(szMessage,_T("%s, %s"),szSound,szText);
69  }
70  }
71  else
72  {
74  {
75  _stprintf(szMessage,_T("%s"),szText);
76  }
77  }
78  }
79  else
80  {
82  {
83  if (LoadString(hApplet, IDS_SOUND, szSound, MAX_PATH))
84  {
85  _stprintf(szMessage,_T("%s"),szSound);
86  }
87  }
88  }
89 
90  SetDlgItemText(hwndDlg, IDC_ALARMMSG1, szMessage);
91 
93  {
94  SetDlgItemText(hwndDlg, IDC_ALARMPROG1, szProgram);
95  }
96  }
97 
99  {
100  CheckDlgButton(hwndDlg, IDC_ALARM2,
102 
103  if (LoadString(hApplet, IDS_PERCENT, szTemp, MAX_PATH))
104  {
106  SetDlgItemText(hwndDlg, IDC_ALARMVALUE2, szBatteryLevel);
107  }
108 
110  TBM_SETRANGE,
111  (WPARAM)TRUE,
112  (LPARAM)MAKELONG(0, 100));
114  TBM_SETPOS,
115  (WPARAM)TRUE,
117 
119  {
120  SetDlgItemText(hwndDlg, IDC_ALARMAKTION2, szAction);
121  }
122 
123  memset(szMessage, 0x0, sizeof(szMessage));
124  LoadString(hApplet, IDS_NOACTION, szMessage, MAX_PATH);
125 
127  {
129  {
131  {
132  _stprintf(szMessage,_T("%s, %s"),szSound,szText);
133  }
134  }
135  else
136  {
138  {
139  _stprintf(szMessage,_T("%s"),szText);
140  }
141  }
142  }
143  else
144  {
146  {
147  if (LoadString(hApplet, IDS_SOUND, szSound, MAX_PATH))
148  {
149  _stprintf(szMessage,_T("%s"),szSound);
150  }
151  }
152  }
153 
154  SetDlgItemText(hwndDlg, IDC_ALARMMSG2, szMessage);
155 
157  {
158  SetDlgItemText(hwndDlg, IDC_ALARMPROG2, szProgram);
159  }
160  }
161 
162  return TRUE;
163 }
164 
165 /* Property page dialog callback */
168  UINT uMsg,
169  WPARAM wParam,
170  LPARAM lParam)
171 {
174  switch(uMsg)
175  {
176  case WM_INITDIALOG:
177  if (!Ala_InitData(hwndDlg))
178  {
179  // TODO:
180  // Handle initialization error
181  }
182  return TRUE;
183  default:
184  break;
185  }
186  return FALSE;
187 }
#define IDC_ALARMBAR1
Definition: resource.h:82
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDC_ALARMVALUE1
Definition: resource.h:84
#define TRUE
Definition: types.h:120
GLint x0
Definition: linetemp.h:95
GLOBAL_USER_POWER_POLICY user
Definition: powrprof.h:42
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CALLBACK
Definition: compat.h:27
#define TBM_SETRANGE
Definition: commctrl.h:2009
#define TBM_SETPOS
Definition: commctrl.h:2008
HINSTANCE hApplet
Definition: access.c:17
static BOOLEAN Ala_InitData(HWND hwndDlg)
Definition: alarms.c:15
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5708
int32_t INT_PTR
Definition: typedefs.h:62
POWER_ACTION_POLICY PowerPolicy
Definition: winnt_old.h:3731
WPARAM wParam
Definition: combotst.c:138
static const WCHAR szText[]
Definition: dialog.c:139
#define POWER_LEVEL_USER_NOTIFY_SOUND
Definition: ntpoapi.h:424
#define IDS_SOUND
Definition: resource.h:9
#define MAKELONG(a, b)
Definition: typedefs.h:248
unsigned char BOOLEAN
POWER_ACTION Action
Definition: ntpoapi.h:408
LONG_PTR LPARAM
Definition: windef.h:208
#define TBM_SETTICFREQ
Definition: commctrl.h:2022
GLOBAL_POWER_POLICY gGPP
Definition: powercfg.c:23
#define IDC_ALARMMSG1
Definition: resource.h:81
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define IDC_ALARMAKTION1
Definition: resource.h:88
#define MAX_PATH
Definition: compat.h:26
#define IDS_NOACTION
Definition: resource.h:22
#define SetDlgItemText
Definition: winuser.h:5715
#define IDS_PowerActionNone2
Definition: resource.h:31
#define BST_UNCHECKED
Definition: winuser.h:199
#define IDS_PERCENT
Definition: resource.h:8
#define IDC_ALARMPROG1
Definition: resource.h:89
#define _stprintf
Definition: utility.h:124
INT_PTR CALLBACK AlarmsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: alarms.c:167
SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES]
Definition: powrprof.h:38
BOOLEAN WINAPI ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY pGlobalPowerPolicy)
Definition: powrprof.c:521
unsigned int UINT
Definition: ndis.h:50
#define BST_CHECKED
Definition: winuser.h:197
#define IDS_TEXT
Definition: resource.h:3
#define IDC_ALARMPROG2
Definition: resource.h:92
#define memset(x, y, z)
Definition: compat.h:39
#define DISCHARGE_POLICY_LOW
Definition: ntpoapi.h:431
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define IDC_ALARMAKTION2
Definition: resource.h:91
#define LoadString
Definition: winuser.h:5685
#define IDC_ALARM2
Definition: resource.h:87
#define POWER_LEVEL_USER_NOTIFY_TEXT
Definition: ntpoapi.h:423
#define IDC_ALARM1
Definition: resource.h:86
#define IDC_ALARMMSG2
Definition: resource.h:90
#define IDC_ALARMVALUE2
Definition: resource.h:85
#define DISCHARGE_POLICY_CRITICAL
Definition: ntpoapi.h:430
#define IDC_ALARMBAR2
Definition: resource.h:83
#define IDS_PowerActionNone1
Definition: resource.h:23