ReactOS  0.4.15-dev-1184-g23e04ae
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  TCHAR Caption[1024];
193  INT nPage = 0;
194  INT ret;
195 
196  if (uMsg == CPL_STARTWPARMSW && lParam != 0)
197  nPage = _wtoi((PWSTR)lParam);
198 
199  LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
200 
201  pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
202  if (pGlobalData == NULL)
203  return 0;
204 
205  if (!ReadSettings(pGlobalData))
206  {
207  HeapFree(GetProcessHeap(), 0, pGlobalData);
208  return 0;
209  }
210 
211  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
212  psh.dwSize = sizeof(PROPSHEETHEADER);
214  psh.hwndParent = hwnd;
215  psh.hInstance = hApplet;
216  psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLACCESS);
217  psh.pszCaption = Caption;
218  psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
219  psh.nStartPage = 0;
220  psh.ppsp = psp;
221  psh.pfnCallback = PropSheetProc;
222 
224  InitPropSheetPage(&psp[1], IDD_PROPPAGESOUND, SoundPageProc, pGlobalData);
225  InitPropSheetPage(&psp[2], IDD_PROPPAGEDISPLAY, DisplayPageProc, pGlobalData);
226  InitPropSheetPage(&psp[3], IDD_PROPPAGEMOUSE, MousePageProc, pGlobalData);
227  InitPropSheetPage(&psp[4], IDD_PROPPAGEGENERAL, GeneralPageProc, pGlobalData);
228 
229  if (nPage != 0 && nPage <= psh.nPages)
230  psh.nStartPage = nPage;
231 
232  ret = PropertySheet(&psh);
233 
234  HeapFree(GetProcessHeap(), 0, pGlobalData);
235 
236  return (LONG)(ret != -1);
237 }
238 
239 /* Control Panel Callback */
241 CPlApplet(HWND hwndCPl,
242  UINT uMsg,
243  LPARAM lParam1,
244  LPARAM lParam2)
245 {
246  INT i = (INT)lParam1;
247 
248  switch (uMsg)
249  {
250  case CPL_INIT:
251  return TRUE;
252 
253  case CPL_GETCOUNT:
254  return NUM_APPLETS;
255 
256  case CPL_INQUIRE:
257  {
258  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
259  CPlInfo->lData = 0;
260  CPlInfo->idIcon = Applets[i].idIcon;
261  CPlInfo->idName = Applets[i].idName;
262  CPlInfo->idInfo = Applets[i].idDescription;
263  }
264  break;
265 
266  case CPL_DBLCLK:
267  Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
268  break;
269 
270  case CPL_STARTWPARMSW:
271  return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
272  }
273 
274  return FALSE;
275 }
276 
277 
278 BOOL WINAPI
280  DWORD dwReason,
282 {
284 
285  switch (dwReason)
286  {
287  case DLL_PROCESS_ATTACH:
288  case DLL_THREAD_ATTACH:
289  hApplet = hinstDLL;
290  break;
291  }
292 
293  return TRUE;
294 }
295 
#define RegQueryValueEx
Definition: winreg.h:524
#define SPI_GETSTICKYKEYS
Definition: winuser.h:1389
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
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:241
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:3448
#define SPI_GETMOUSEKEYS
Definition: winuser.h:1385
#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
#define INT
Definition: polytest.cpp:20
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:5833
int idInfo
Definition: cpl.h:27
SERIALKEYS serialKeys
Definition: access.h:54
#define ZeroMemory
Definition: winbase.h:1648
#define IDD_PROPPAGEMOUSE
Definition: resource.h:9
SERIALKEYSA SERIALKEYS
Definition: winuser.h:5699
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:5700
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:3509
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
#define SPI_GETSOUNDSENTRY
Definition: winuser.h:1397
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
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:279
SOUNDSENTRY ssSoundSentry
Definition: access.h:38
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:392
#define SPI_GETSHOWSOUNDS
Definition: winuser.h:1387
LONG_PTR LPARAM
Definition: windef.h:208
struct tagSTICKYKEYS STICKYKEYS
#define SPI_GETACCESSTIMEOUT
Definition: winuser.h:1391
LPSTR lpszPort
Definition: winuser.h:3449
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
char TCHAR
Definition: xmlstorage.h:189
#define PSP_DEFAULT
Definition: prsht.h:22
struct tagMOUSEKEYS MOUSEKEYS
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:484
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:3504
HIGHCONTRASTA HIGHCONTRAST
Definition: winuser.h:5698
#define SPI_GETFILTERKEYS
Definition: winuser.h:1381
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:2871
#define PSCB_INITIALIZED
Definition: prsht.h:75
UINT uCaretBlinkTime
Definition: access.h:43
HICON hIcon
Definition: msconfig.c:44
#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:1383
#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 HEAP_ZERO_MEMORY
Definition: compat.h:134
UINT cbSize
Definition: winuser.h:3386
#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
#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:483
#define CPL_GETCOUNT
Definition: cpl.h:13
#define LoadString
Definition: winuser.h:5794
#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