ReactOS  0.4.15-dev-5109-g2469ce2
access.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Accessibility Control Panel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/cpl/access/access.c
5  * PURPOSE: Main control panel code
6  * COPYRIGHT: Copyright 2004 Johannes Anderwald (johannes.anderwald@reactos.org)
7  * Copyright 2007 Eric Kohl
8  */
9 
10 #include "access.h"
11 
12 #include <cpl.h>
13 
14 #define NUM_APPLETS (1)
15 
18 
19 /* Applets */
21 {
23 };
24 
25 
26 static BOOL
28 {
29  DWORD dwDisposition;
31  HKEY hKey;
32  LONG lError;
33 
34  /* Get sticky keys information */
35  pGlobalData->stickyKeys.cbSize = sizeof(STICKYKEYS);
37  sizeof(STICKYKEYS),
38  &pGlobalData->stickyKeys,
39  0))
40  return FALSE;
41 
42  /* Get filter keys information */
43  pGlobalData->filterKeys.cbSize = sizeof(FILTERKEYS);
45  sizeof(FILTERKEYS),
46  &pGlobalData->filterKeys,
47  0))
48  return FALSE;
49 
50  /* Get toggle keys information */
51  pGlobalData->toggleKeys.cbSize = sizeof(TOGGLEKEYS);
53  sizeof(TOGGLEKEYS),
54  &pGlobalData->toggleKeys,
55  0))
56  return FALSE;
57 
58  /* Get keyboard preference information */
59  if (!SystemParametersInfo(SPI_GETKEYBOARDPREF,
60  0,
61  &pGlobalData->bKeyboardPref,
62  0))
63  return FALSE;
64 
65  /* Get high contrast information */
66  pGlobalData->highContrast.cbSize = sizeof(HIGHCONTRAST);
67  SystemParametersInfo(SPI_GETHIGHCONTRAST,
68  sizeof(HIGHCONTRAST),
69  &pGlobalData->highContrast,
70  0);
71 
72  SystemParametersInfo(SPI_GETCARETWIDTH,
73  0,
74  &pGlobalData->uCaretWidth,
75  0);
76 
77  pGlobalData->uCaretBlinkTime = GetCaretBlinkTime();
78 
79  /* Get sound settings */
80  pGlobalData->ssSoundSentry.cbSize = sizeof(SOUNDSENTRY);
82  sizeof(SOUNDSENTRY),
83  &pGlobalData->ssSoundSentry,
84  0);
85 
87  0,
88  &pGlobalData->bShowSounds,
89  0);
90 
91  /* Get mouse keys information */
92  pGlobalData->mouseKeys.cbSize = sizeof(MOUSEKEYS);
94  sizeof(MOUSEKEYS),
95  &pGlobalData->mouseKeys,
96  0);
97 
98  /* Get access timeout information */
99  pGlobalData->accessTimeout.cbSize = sizeof(ACCESSTIMEOUT);
101  sizeof(ACCESSTIMEOUT),
102  &pGlobalData->accessTimeout,
103  0);
104 
105  /* Get serial keys information */
106  pGlobalData->serialKeys.cbSize = sizeof(SERIALKEYS);
107  pGlobalData->serialKeys.lpszActivePort = pGlobalData->szActivePort;
108  pGlobalData->serialKeys.lpszPort = pGlobalData->szPort;
109  SystemParametersInfo(SPI_GETSERIALKEYS,
110  sizeof(SERIALKEYS),
111  &pGlobalData->serialKeys,
112  0);
113 
114  pGlobalData->bWarningSounds = TRUE;
115  pGlobalData->bSoundOnActivation = TRUE;
116 
118  _T("Control Panel\\Accessibility"),
119  0,
120  NULL,
123  NULL,
124  &hKey,
125  &dwDisposition);
126  if (lError != ERROR_SUCCESS)
127  return TRUE;
128 
129  dwLength = sizeof(BOOL);
130  lError = RegQueryValueEx(hKey,
131  _T("Warning Sounds"),
132  NULL,
133  NULL,
134  (LPBYTE)&pGlobalData->bWarningSounds,
135  &dwLength);
136  if (lError != ERROR_SUCCESS)
137  pGlobalData->bWarningSounds = TRUE;
138 
139  dwLength = sizeof(BOOL);
140  lError = RegQueryValueEx(hKey,
141  _T("Sound On Activation"),
142  NULL,
143  NULL,
144  (LPBYTE)&pGlobalData->bSoundOnActivation,
145  &dwLength);
146  if (lError != ERROR_SUCCESS)
147  pGlobalData->bSoundOnActivation = TRUE;
148 
149  RegCloseKey(hKey);
150 
151  return TRUE;
152 }
153 
154 
155 static VOID
157 {
158  ZeroMemory(psp, sizeof(PROPSHEETPAGE));
159  psp->dwSize = sizeof(PROPSHEETPAGE);
160  psp->dwFlags = PSP_DEFAULT;
161  psp->hInstance = hApplet;
162  psp->pszTemplate = MAKEINTRESOURCE(idDlg);
163  psp->pfnDlgProc = DlgProc;
164  psp->lParam = (LPARAM)pGlobalData;
165 }
166 
167 static int CALLBACK
169 {
170  // NOTE: This callback is needed to set large icon correctly.
171  HICON hIcon;
172  switch (uMsg)
173  {
174  case PSCB_INITIALIZED:
175  {
177  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
178  break;
179  }
180  }
181  return 0;
182 }
183 
184 /* First Applet */
185 
188 {
189  PGLOBAL_DATA pGlobalData;
190  PROPSHEETPAGE psp[5];
191  PROPSHEETHEADER psh;
192  INT nPage = 0;
193  INT ret;
194 
195  if (uMsg == CPL_STARTWPARMSW && lParam != 0)
196  nPage = _wtoi((PWSTR)lParam);
197 
198  pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
199  if (pGlobalData == NULL)
200  return 0;
201 
202  if (!ReadSettings(pGlobalData))
203  {
204  HeapFree(GetProcessHeap(), 0, pGlobalData);
205  return 0;
206  }
207 
208  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
209  psh.dwSize = sizeof(PROPSHEETHEADER);
211  psh.hwndParent = hwnd;
212  psh.hInstance = hApplet;
213  psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLACCESS);
214  psh.pszCaption = MAKEINTRESOURCEW(IDS_CPLSYSTEMNAME);
215  psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
216  psh.nStartPage = 0;
217  psh.ppsp = psp;
218  psh.pfnCallback = PropSheetProc;
219 
221  InitPropSheetPage(&psp[1], IDD_PROPPAGESOUND, SoundPageProc, pGlobalData);
222  InitPropSheetPage(&psp[2], IDD_PROPPAGEDISPLAY, DisplayPageProc, pGlobalData);
223  InitPropSheetPage(&psp[3], IDD_PROPPAGEMOUSE, MousePageProc, pGlobalData);
224  InitPropSheetPage(&psp[4], IDD_PROPPAGEGENERAL, GeneralPageProc, pGlobalData);
225 
226  if (nPage != 0 && nPage <= psh.nPages)
227  psh.nStartPage = nPage;
228 
229  ret = PropertySheet(&psh);
230 
231  HeapFree(GetProcessHeap(), 0, pGlobalData);
232 
233  return (LONG)(ret != -1);
234 }
235 
236 /* Control Panel Callback */
238 CPlApplet(HWND hwndCPl,
239  UINT uMsg,
240  LPARAM lParam1,
241  LPARAM lParam2)
242 {
243  UINT i = (UINT)lParam1;
244 
245  switch (uMsg)
246  {
247  case CPL_INIT:
248  return TRUE;
249 
250  case CPL_GETCOUNT:
251  return NUM_APPLETS;
252 
253  case CPL_INQUIRE:
254  if (i < NUM_APPLETS)
255  {
256  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
257  CPlInfo->lData = 0;
258  CPlInfo->idIcon = Applets[i].idIcon;
259  CPlInfo->idName = Applets[i].idName;
260  CPlInfo->idInfo = Applets[i].idDescription;
261  }
262  else
263  {
264  return TRUE;
265  }
266  break;
267 
268  case CPL_DBLCLK:
269  if (i < NUM_APPLETS)
270  Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
271  else
272  return TRUE;
273  break;
274 
275  case CPL_STARTWPARMSW:
276  if (i < NUM_APPLETS)
277  return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
278  break;
279  }
280 
281  return FALSE;
282 }
283 
284 
285 BOOL WINAPI
287  DWORD dwReason,
289 {
291 
292  switch (dwReason)
293  {
294  case DLL_PROCESS_ATTACH:
295  case DLL_THREAD_ATTACH:
296  hApplet = hinstDLL;
297  break;
298  }
299 
300  return TRUE;
301 }
302 
#define RegQueryValueEx
Definition: winreg.h:524
#define SPI_GETSTICKYKEYS
Definition: winuser.h:1397
WORD idDlg
Definition: desk.c:110
#define MAKEINTRESOURCE
Definition: winuser.h:591
LONG CALLBACK CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: access.c:238
static HICON
Definition: imagelist.c:84
TOGGLEKEYS toggleKeys
Definition: access.h:33
static BOOL ReadSettings(PGLOBAL_DATA pGlobalData)
Definition: access.c:27
Definition: cpl.h:24
#define ERROR_SUCCESS
Definition: deptool.c:10
INT_PTR CALLBACK DisplayPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: display.c:127
TCHAR szActivePort[MAX_PATH]
Definition: access.h:55
LPSTR lpszActivePort
Definition: winuser.h:3463
#define SPI_GETMOUSEKEYS
Definition: winuser.h:1393
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define DLL_THREAD_ATTACH
Definition: compat.h:132
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL bShowSounds
Definition: access.h:39
#define HKEY_CURRENT_USER
Definition: winreg.h:11
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
int idName
Definition: hotplug.h:36
int idIcon
Definition: hotplug.h:35
#define CALLBACK
Definition: compat.h:35
static VOID InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, PGLOBAL_DATA pGlobalData)
Definition: access.c:156
#define SystemParametersInfo
Definition: winuser.h:5848
int idInfo
Definition: cpl.h:27
SERIALKEYS serialKeys
Definition: access.h:54
#define ZeroMemory
Definition: winbase.h:1667
#define IDD_PROPPAGEMOUSE
Definition: resource.h:9
SERIALKEYSA SERIALKEYS
Definition: winuser.h:5714
HINSTANCE hApplet
Definition: access.c:17
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL bWarningSounds
Definition: access.h:57
SOUNDSENTRYA SOUNDSENTRY
Definition: winuser.h:5715
FILTERKEYS filterKeys
Definition: access.h:31
#define PSH_USECALLBACK
Definition: prsht.h:48
#define BOOL
Definition: nt_native.h:43
int32_t INT
Definition: typedefs.h:58
APPLET Applets[NUM_APPLETS]
Definition: access.c:20
WPARAM wParam
Definition: combotst.c:138
static IN DWORD IN LPVOID lpvReserved
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:37
#define CPL_DBLCLK
Definition: cpl.h:16
DWORD dwReason
Definition: misc.cpp:154
DWORD cbSize
Definition: winuser.h:3524
#define SPI_GETSOUNDSENTRY
Definition: winuser.h:1405
unsigned char * LPBYTE
Definition: typedefs.h:53
#define PSH_USEICONID
Definition: prsht.h:42
#define FALSE
Definition: types.h:117
INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDD_PROPPAGEDISPLAY
Definition: resource.h:8
long LONG
Definition: pedump.c:60
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
Definition: access.c:286
SOUNDSENTRY ssSoundSentry
Definition: access.h:38
#define PROPSHEETHEADER
Definition: prsht.h:392
#define SPI_GETSHOWSOUNDS
Definition: winuser.h:1395
LONG_PTR LPARAM
Definition: windef.h:208
struct tagSTICKYKEYS STICKYKEYS
#define SPI_GETACCESSTIMEOUT
Definition: winuser.h:1399
LPSTR lpszPort
Definition: winuser.h:3464
UINT WINAPI GetCaretBlinkTime(void)
Definition: ntwrapper.h:166
#define IDS_CPLSYSTEMNAME
Definition: resource.h:23
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define PSP_DEFAULT
Definition: prsht.h:22
struct tagMOUSEKEYS MOUSEKEYS
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static DWORD DWORD * dwLength
Definition: fusion.c:85
static LONG CALLBACK SystemApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: access.c:187
APPLET_PROC AppletProc
Definition: hotplug.h:38
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
STICKYKEYS stickyKeys
Definition: access.h:29
#define CPL_STARTWPARMSW
Definition: cpl.h:21
#define CPL_INIT
Definition: cpl.h:12
MOUSEKEYS mouseKeys
Definition: access.h:50
#define IDD_PROPPAGEGENERAL
Definition: resource.h:10
int ret
#define CPL_INQUIRE
Definition: cpl.h:14
DWORD cbSize
Definition: winuser.h:3519
HIGHCONTRASTA HIGHCONTRAST
Definition: winuser.h:5713
#define SPI_GETFILTERKEYS
Definition: winuser.h:1389
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
#define IDI_CPLACCESS
Definition: resource.h:4
TCHAR szPort[MAX_PATH]
Definition: access.h:56
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2886
#define PSCB_INITIALIZED
Definition: prsht.h:75
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT uCaretBlinkTime
Definition: access.h:43
HICON hIcon
Definition: msconfig.c:44
FxAutoRegKey hKey
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
HIGHCONTRAST highContrast
Definition: access.h:42
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL bSoundOnActivation
Definition: access.h:58
BOOL bKeyboardPref
Definition: access.h:35
ACCESSTIMEOUT accessTimeout
Definition: access.h:53
#define SPI_GETTOGGLEKEYS
Definition: winuser.h:1391
#define IDD_PROPPAGEKEYBOARD
Definition: resource.h:6
#define KEY_EXECUTE
Definition: nt_native.h:1037
#define IDS_CPLSYSTEMDESCRIPTION
Definition: resource.h:24
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
UINT cbSize
Definition: winuser.h:3401
#define PropertySheet
Definition: prsht.h:400
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: access.c:168
struct tagTOGGLEKEYS TOGGLEKEYS
INT_PTR CALLBACK SoundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: sound.c:56
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDD_PROPPAGESOUND
Definition: resource.h:7
UINT uCaretWidth
Definition: access.h:44
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
#define NUM_APPLETS
Definition: access.c:14
INT_PTR CALLBACK KeyboardPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: keyboard.c:576
struct tagACCESSTIMEOUT ACCESSTIMEOUT
LPARAM lParam
Definition: combotst.c:139
DLGPROC DlgProc
Definition: desk.c:111
#define HeapFree(x, y, z)
Definition: compat.h:594
#define CPL_GETCOUNT
Definition: cpl.h:13
#define RegCloseKey(hKey)
Definition: registry.h:47
#define RegCreateKeyEx
Definition: winreg.h:501
#define PROPSHEETPAGE
Definition: prsht.h:389
struct tagFILTERKEYS FILTERKEYS
INT_PTR CALLBACK MousePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: mouse.c:142
#define ICON_BIG
Definition: tnclass.cpp:51
Definition: hotplug.h:33