ReactOS 0.4.16-dev-306-g647d351
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
26static 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
150
151 return TRUE;
152}
153
154
155static 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
167static 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);
223 InitPropSheetPage(&psp[3], IDD_PROPPAGEMOUSE, MousePageProc, 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 */
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
289{
291
292 switch (dwReason)
293 {
296 hApplet = hinstDLL;
297 break;
298 }
299
300 return TRUE;
301}
302
INT_PTR CALLBACK SoundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: sound.c:56
INT_PTR CALLBACK DisplayPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: display.c:152
INT_PTR CALLBACK KeyboardPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: keyboard.c:576
INT_PTR CALLBACK MousePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: mouse.c:142
INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
DWORD dwReason
Definition: misc.cpp:141
#define RegCloseKey(hKey)
Definition: registry.h:49
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define CPL_INQUIRE
Definition: cpl.h:14
#define CPL_DBLCLK
Definition: cpl.h:16
#define CPL_STARTWPARMSW
Definition: cpl.h:21
#define CPL_INIT
Definition: cpl.h:12
#define CPL_GETCOUNT
Definition: cpl.h:13
#define DLGPROC
Definition: maze.c:62
#define ERROR_SUCCESS
Definition: deptool.c:10
WORD idDlg
Definition: desk.c:121
DLGPROC DlgProc
Definition: desk.c:122
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NUM_APPLETS
Definition: access.c:14
static LONG CALLBACK SystemApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: access.c:187
static VOID InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, PGLOBAL_DATA pGlobalData)
Definition: access.c:156
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: access.c:168
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
Definition: access.c:286
APPLET Applets[NUM_APPLETS]
Definition: access.c:20
static BOOL ReadSettings(PGLOBAL_DATA pGlobalData)
Definition: access.c:27
HINSTANCE hApplet
Definition: access.c:17
#define IDS_CPLSYSTEMNAME
Definition: resource.h:23
#define IDI_CPLACCESS
Definition: resource.h:4
#define IDD_PROPPAGEDISPLAY
Definition: resource.h:8
#define IDD_PROPPAGEMOUSE
Definition: resource.h:9
#define IDS_CPLSYSTEMDESCRIPTION
Definition: resource.h:24
#define IDD_PROPPAGEKEYBOARD
Definition: resource.h:6
#define IDD_PROPPAGEGENERAL
Definition: resource.h:10
#define IDD_PROPPAGESOUND
Definition: resource.h:7
#define GetProcessHeap()
Definition: compat.h:736
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define DLL_THREAD_ATTACH
Definition: compat.h:132
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static DWORD DWORD * dwLength
Definition: fusion.c:86
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
FxAutoRegKey hKey
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
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
static IN DWORD IN LPVOID lpvReserved
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_EXECUTE
Definition: nt_native.h:1037
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
long LONG
Definition: pedump.c:60
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSP_DEFAULT
Definition: prsht.h:22
#define PropertySheet
Definition: prsht.h:400
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
#define PSH_USEICONID
Definition: prsht.h:42
#define PSCB_INITIALIZED
Definition: prsht.h:75
#define PROPSHEETPAGE
Definition: prsht.h:389
Definition: hotplug.h:34
int idDescription
Definition: hotplug.h:37
int idName
Definition: hotplug.h:36
int idIcon
Definition: hotplug.h:35
APPLET_PROC AppletProc
Definition: hotplug.h:38
BOOL bShowSounds
Definition: access.h:39
STICKYKEYS stickyKeys
Definition: access.h:29
ACCESSTIMEOUT accessTimeout
Definition: access.h:53
BOOL bWarningSounds
Definition: access.h:57
TCHAR szActivePort[MAX_PATH]
Definition: access.h:55
TOGGLEKEYS toggleKeys
Definition: access.h:33
UINT uCaretWidth
Definition: access.h:44
SERIALKEYS serialKeys
Definition: access.h:54
FILTERKEYS filterKeys
Definition: access.h:31
UINT uCaretBlinkTime
Definition: access.h:43
BOOL bKeyboardPref
Definition: access.h:35
TCHAR szPort[MAX_PATH]
Definition: access.h:56
SOUNDSENTRY ssSoundSentry
Definition: access.h:38
MOUSEKEYS mouseKeys
Definition: access.h:50
BOOL bSoundOnActivation
Definition: access.h:58
HIGHCONTRAST highContrast
Definition: access.h:42
Definition: cpl.h:24
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25
UINT cbSize
Definition: winuser.h:3414
LPSTR lpszPort
Definition: winuser.h:3477
LPSTR lpszActivePort
Definition: winuser.h:3476
DWORD cbSize
Definition: winuser.h:3532
DWORD cbSize
Definition: winuser.h:3537
#define ICON_BIG
Definition: tnclass.cpp:51
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
int ret
#define ZeroMemory
Definition: winbase.h:1737
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegCreateKeyEx
Definition: winreg.h:501
#define RegQueryValueEx
Definition: winreg.h:524
#define SPI_GETFILTERKEYS
Definition: winuser.h:1402
#define SPI_GETACCESSTIMEOUT
Definition: winuser.h:1412
SERIALKEYSA SERIALKEYS
Definition: winuser.h:5736
#define SPI_GETMOUSEKEYS
Definition: winuser.h:1406
#define SPI_GETSHOWSOUNDS
Definition: winuser.h:1408
#define SPI_GETTOGGLEKEYS
Definition: winuser.h:1404
struct tagSTICKYKEYS STICKYKEYS
struct tagMOUSEKEYS MOUSEKEYS
struct tagFILTERKEYS FILTERKEYS
HIGHCONTRASTA HIGHCONTRAST
Definition: winuser.h:5735
SOUNDSENTRYA SOUNDSENTRY
Definition: winuser.h:5737
#define SPI_GETSTICKYKEYS
Definition: winuser.h:1410
struct tagACCESSTIMEOUT ACCESSTIMEOUT
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SystemParametersInfo
Definition: winuser.h:5870
#define SPI_GETSOUNDSENTRY
Definition: winuser.h:1418
#define MAKEINTRESOURCE
Definition: winuser.h:591
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2127
struct tagTOGGLEKEYS TOGGLEKEYS
UINT WINAPI GetCaretBlinkTime(void)
Definition: ntwrapper.h:166
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)