ReactOS  0.4.14-dev-608-gd495a4f
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 
19 
20 /* Applets */
22 {
24 };
25 
26 
27 static BOOL
29 {
30  DWORD dwDisposition;
32  HKEY hKey;
33  LONG lError;
34 
35  /* Get sticky keys information */
36  pGlobalData->stickyKeys.cbSize = sizeof(STICKYKEYS);
38  sizeof(STICKYKEYS),
39  &pGlobalData->stickyKeys,
40  0))
41  return FALSE;
42 
43  /* Get filter keys information */
44  pGlobalData->filterKeys.cbSize = sizeof(FILTERKEYS);
46  sizeof(FILTERKEYS),
47  &pGlobalData->filterKeys,
48  0))
49  return FALSE;
50 
51  /* Get toggle keys information */
52  pGlobalData->toggleKeys.cbSize = sizeof(TOGGLEKEYS);
54  sizeof(TOGGLEKEYS),
55  &pGlobalData->toggleKeys,
56  0))
57  return FALSE;
58 
59  /* Get keyboard preference information */
60  if (!SystemParametersInfo(SPI_GETKEYBOARDPREF,
61  0,
62  &pGlobalData->bKeyboardPref,
63  0))
64  return FALSE;
65 
66  /* Get high contrast information */
67  pGlobalData->highContrast.cbSize = sizeof(HIGHCONTRAST);
68  SystemParametersInfo(SPI_GETHIGHCONTRAST,
69  sizeof(HIGHCONTRAST),
70  &pGlobalData->highContrast,
71  0);
72 
73  SystemParametersInfo(SPI_GETCARETWIDTH,
74  0,
75  &pGlobalData->uCaretWidth,
76  0);
77 
78  pGlobalData->uCaretBlinkTime = GetCaretBlinkTime();
79 
80  /* Get sound settings */
81  pGlobalData->ssSoundSentry.cbSize = sizeof(SOUNDSENTRY);
83  sizeof(SOUNDSENTRY),
84  &pGlobalData->ssSoundSentry,
85  0);
86 
88  0,
89  &pGlobalData->bShowSounds,
90  0);
91 
92  /* Get mouse keys information */
93  pGlobalData->mouseKeys.cbSize = sizeof(MOUSEKEYS);
95  sizeof(MOUSEKEYS),
96  &pGlobalData->mouseKeys,
97  0);
98 
99  /* Get access timeout information */
100  pGlobalData->accessTimeout.cbSize = sizeof(ACCESSTIMEOUT);
102  sizeof(ACCESSTIMEOUT),
103  &pGlobalData->accessTimeout,
104  0);
105 
106  /* Get serial keys information */
107  pGlobalData->serialKeys.cbSize = sizeof(SERIALKEYS);
108  pGlobalData->serialKeys.lpszActivePort = pGlobalData->szActivePort;
109  pGlobalData->serialKeys.lpszPort = pGlobalData->szPort;
110  SystemParametersInfo(SPI_GETSERIALKEYS,
111  sizeof(SERIALKEYS),
112  &pGlobalData->serialKeys,
113  0);
114 
115  pGlobalData->bWarningSounds = TRUE;
116  pGlobalData->bSoundOnActivation = TRUE;
117 
119  _T("Control Panel\\Accessibility"),
120  0,
121  NULL,
124  NULL,
125  &hKey,
126  &dwDisposition);
127  if (lError != ERROR_SUCCESS)
128  return TRUE;
129 
130  dwLength = sizeof(BOOL);
131  lError = RegQueryValueEx(hKey,
132  _T("Warning Sounds"),
133  NULL,
134  NULL,
135  (LPBYTE)&pGlobalData->bWarningSounds,
136  &dwLength);
137  if (lError != ERROR_SUCCESS)
138  pGlobalData->bWarningSounds = TRUE;
139 
140  dwLength = sizeof(BOOL);
141  lError = RegQueryValueEx(hKey,
142  _T("Sound On Activation"),
143  NULL,
144  NULL,
145  (LPBYTE)&pGlobalData->bSoundOnActivation,
146  &dwLength);
147  if (lError != ERROR_SUCCESS)
148  pGlobalData->bSoundOnActivation = TRUE;
149 
150  RegCloseKey(hKey);
151 
152  return TRUE;
153 }
154 
155 
156 static VOID
158 {
159  ZeroMemory(psp, sizeof(PROPSHEETPAGE));
160  psp->dwSize = sizeof(PROPSHEETPAGE);
161  psp->dwFlags = PSP_DEFAULT;
162  psp->hInstance = hApplet;
163  psp->pszTemplate = MAKEINTRESOURCE(idDlg);
164  psp->pfnDlgProc = DlgProc;
165  psp->lParam = (LPARAM)pGlobalData;
166 }
167 
168 static int CALLBACK
170 {
171  // NOTE: This callback is needed to set large icon correctly.
172  HICON hIcon;
173  switch (uMsg)
174  {
175  case PSCB_INITIALIZED:
176  {
178  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
179  break;
180  }
181  }
182  return 0;
183 }
184 
185 /* First Applet */
186 
189 {
190  PGLOBAL_DATA pGlobalData;
191  PROPSHEETPAGE psp[5];
192  PROPSHEETHEADER psh;
193  TCHAR Caption[1024];
194  INT ret;
195 
196  LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
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 = hCPLWindow;
212  psh.hInstance = hApplet;
213  psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLACCESS);
214  psh.pszCaption = Caption;
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  ret = PropertySheet(&psh);
227 
228  HeapFree(GetProcessHeap(), 0, pGlobalData);
229 
230  return (LONG)(ret != -1);
231 }
232 
233 /* Control Panel Callback */
235 CPlApplet(HWND hwndCPl,
236  UINT uMsg,
237  LPARAM lParam1,
238  LPARAM lParam2)
239 {
240  INT i = (INT)lParam1;
241 
242  switch (uMsg)
243  {
244  case CPL_INIT:
245  return TRUE;
246 
247  case CPL_GETCOUNT:
248  return NUM_APPLETS;
249 
250  case CPL_INQUIRE:
251  {
252  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
253  CPlInfo->lData = 0;
254  CPlInfo->idIcon = Applets[i].idIcon;
255  CPlInfo->idName = Applets[i].idName;
256  CPlInfo->idInfo = Applets[i].idDescription;
257  }
258  break;
259 
260  case CPL_DBLCLK:
261  hCPLWindow = hwndCPl;
262  Applets[i].AppletProc();
263  break;
264  }
265 
266  return FALSE;
267 }
268 
269 
270 BOOL WINAPI
272  DWORD dwReason,
274 {
276 
277  switch (dwReason)
278  {
279  case DLL_PROCESS_ATTACH:
280  case DLL_THREAD_ATTACH:
281  hApplet = hinstDLL;
282  break;
283  }
284 
285  return TRUE;
286 }
287 
#define RegQueryValueEx
Definition: winreg.h:524
#define SPI_GETSTICKYKEYS
Definition: winuser.h:1389
WORD idDlg
Definition: desk.c:109
#define MAKEINTRESOURCE
Definition: winuser.h:591
LONG CALLBACK CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: access.c:235
static HICON
Definition: imagelist.c:84
HWND hCPLWindow
Definition: access.c:18
#define TRUE
Definition: types.h:120
TOGGLEKEYS toggleKeys
Definition: access.h:34
static BOOL ReadSettings(PGLOBAL_DATA pGlobalData)
Definition: access.c:28
Definition: cpl.h:24
LONG CALLBACK SystemApplet(VOID)
Definition: access.c:188
#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:56
LPSTR lpszActivePort
Definition: winuser.h:3448
#define SPI_GETMOUSEKEYS
Definition: winuser.h:1385
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define DLL_THREAD_ATTACH
Definition: compat.h:121
BOOL bShowSounds
Definition: access.h:40
#define HKEY_CURRENT_USER
Definition: winreg.h:11
int idName
Definition: hotplug.h:27
#define INT
Definition: polytest.cpp:20
int idIcon
Definition: hotplug.h:26
#define CALLBACK
Definition: compat.h:27
static VOID InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, PGLOBAL_DATA pGlobalData)
Definition: access.c:157
#define SystemParametersInfo
Definition: winuser.h:5833
int idInfo
Definition: cpl.h:27
SERIALKEYS serialKeys
Definition: access.h:55
#define ZeroMemory
Definition: winbase.h:1642
#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:120
BOOL bWarningSounds
Definition: access.h:58
SOUNDSENTRYA SOUNDSENTRY
Definition: winuser.h:5700
FILTERKEYS filterKeys
Definition: access.h:32
#define PSH_USECALLBACK
Definition: prsht.h:48
#define BOOL
Definition: nt_native.h:43
int32_t INT
Definition: typedefs.h:56
APPLET Applets[NUM_APPLETS]
Definition: access.c:21
static IN DWORD IN LPVOID lpvReserved
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:28
#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:52
#define PSH_USEICONID
Definition: prsht.h:42
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:271
SOUNDSENTRY ssSoundSentry
Definition: access.h:39
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:374
#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:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static DWORD DWORD * dwLength
Definition: fusion.c:85
APPLET_PROC AppletProc
Definition: hotplug.h:29
#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:30
#define CPL_INIT
Definition: cpl.h:12
MOUSEKEYS mouseKeys
Definition: access.h:51
#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:57
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2871
#define PSCB_INITIALIZED
Definition: prsht.h:75
UINT uCaretBlinkTime
Definition: access.h:44
HICON hIcon
Definition: msconfig.c:44
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
HIGHCONTRAST highContrast
Definition: access.h:43
#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:59
BOOL bKeyboardPref
Definition: access.h:36
ACCESSTIMEOUT accessTimeout
Definition: access.h:54
#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:123
UINT cbSize
Definition: winuser.h:3386
#define PropertySheet
Definition: prsht.h:382
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:169
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:45
#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:110
#define HeapFree(x, y, z)
Definition: compat.h:402
#define CPL_GETCOUNT
Definition: cpl.h:13
#define LoadString
Definition: winuser.h:5794
#define RegCreateKeyEx
Definition: winreg.h:501
#define PROPSHEETPAGE
Definition: prsht.h:371
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:24