ReactOS  0.4.13-dev-99-g7e18b6d
mouse.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/mouse.c
5  * PURPOSE: Mouse-related accessibility settings
6  * COPYRIGHT: Copyright 2004 Johannes Anderwald (johannes.anderwald@reactos.org)
7  * Copyright 2007 Eric Kohl
8  */
9 
10 #include "access.h"
11 
12 #define SPEEDTICKS 9
13 #define ACCELTICKS 9
14 
15 static UINT nSpeedArray[SPEEDTICKS] = {10, 20, 30, 40, 60, 80, 120, 180, 360};
16 
17 
20  UINT uMsg,
21  WPARAM wParam,
22  LPARAM lParam)
23 {
24  PGLOBAL_DATA pGlobalData;
25  INT i;
26 
27  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
28 
29  switch (uMsg)
30  {
31  case WM_INITDIALOG:
32  pGlobalData = (PGLOBAL_DATA)lParam;
33  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
34 
35  CheckDlgButton(hwndDlg,
37  pGlobalData->mouseKeys.dwFlags & MKF_HOTKEYACTIVE ? BST_CHECKED : BST_UNCHECKED);
38 
39  /* Set the number of ticks for the speed trackbar */
41  TRUE, MAKELONG(0, SPEEDTICKS - 1));
42 
43  /* Calculate the matching tick */
44  for (i = 0; i < SPEEDTICKS; i++)
45  {
46  if (pGlobalData->mouseKeys.iMaxSpeed <= nSpeedArray[i])
47  break;
48  }
49 
50  /* Set the thumb */
52 
53  /* Set the number of ticks for the acceleration trackbar */
55  TRUE, MAKELONG(0, ACCELTICKS - 1));
56 
57  /* Calculate the matching tick */
58  i = (ACCELTICKS + 1) - pGlobalData->mouseKeys.iTimeToMaxSpeed / 500;
59  if (i > ACCELTICKS - 1)
60  i = ACCELTICKS - 1;
61 
62  if (i < 0)
63  i = 0;
64 
65  /* Set the thumb */
67 
68  CheckDlgButton(hwndDlg,
70  pGlobalData->mouseKeys.dwFlags & MKF_MODIFIERS ? BST_CHECKED : BST_UNCHECKED);
71 
72  CheckRadioButton(hwndDlg,
75  pGlobalData->mouseKeys.dwFlags & MKF_REPLACENUMBERS ? IDC_MOUSEKEYS_ON_RADIO : IDC_MOUSEKEYS_OFF_RADIO);
76 
77  CheckDlgButton(hwndDlg,
79  pGlobalData->mouseKeys.dwFlags & MKF_INDICATOR ? BST_CHECKED : BST_UNCHECKED);
80  break;
81 
82  case WM_HSCROLL:
83  switch (GetWindowLongPtr((HWND) lParam, GWL_ID))
84  {
87  if (i >= 0 && i < SPEEDTICKS)
88  pGlobalData->mouseKeys.iMaxSpeed = nSpeedArray[i];
89  break;
90 
93  if (i >= 0 && i < ACCELTICKS)
94  pGlobalData->mouseKeys.iTimeToMaxSpeed = (ACCELTICKS + 1 - i) * 500;
95  break;
96  }
97  break;
98 
99  case WM_COMMAND:
100  switch (LOWORD(wParam))
101  {
103  pGlobalData->mouseKeys.dwFlags ^= MKF_HOTKEYACTIVE;
104  break;
105 
107  pGlobalData->mouseKeys.dwFlags ^= MKF_MODIFIERS;
108  break;
109 
111  pGlobalData->mouseKeys.dwFlags |= MKF_REPLACENUMBERS;
112  break;
113 
115  pGlobalData->mouseKeys.dwFlags &= ~MKF_REPLACENUMBERS;
116  break;
117 
119  pGlobalData->mouseKeys.dwFlags ^= MKF_INDICATOR;
120  break;
121 
122  case IDOK:
123  EndDialog(hwndDlg, TRUE);
124  break;
125 
126  case IDCANCEL:
127  EndDialog(hwndDlg, FALSE);
128  break;
129 
130  default:
131  break;
132  }
133  break;
134  }
135 
136  return FALSE;
137 }
138 
139 
140 /* Property page dialog callback */
143  UINT uMsg,
144  WPARAM wParam,
145  LPARAM lParam)
146 {
147  PGLOBAL_DATA pGlobalData;
148  LPPSHNOTIFY lppsn;
149 
150  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
151 
152  switch (uMsg)
153  {
154  case WM_INITDIALOG:
155  pGlobalData = (PGLOBAL_DATA)((LPPROPSHEETPAGE)lParam)->lParam;
156  if (pGlobalData == NULL)
157  return FALSE;
158 
159  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
160 
161  /* Set the checkbox */
162  CheckDlgButton(hwndDlg,
164  pGlobalData->mouseKeys.dwFlags & MKF_MOUSEKEYSON ? BST_CHECKED : BST_UNCHECKED);
165  return TRUE;
166 
167 
168  case WM_COMMAND:
169  switch (LOWORD(wParam))
170  {
171  case IDC_MOUSE_BOX:
172  pGlobalData->mouseKeys.dwFlags ^= MKF_MOUSEKEYSON;
173  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
174  break;
175 
176  case IDC_MOUSE_BUTTON:
179  hwndDlg,
181  (LPARAM)pGlobalData))
182  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
183  break;
184 
185  default:
186  break;
187  }
188  break;
189 
190  case WM_NOTIFY:
191  lppsn = (LPPSHNOTIFY)lParam;
192  if (lppsn->hdr.code == PSN_APPLY)
193  {
195  sizeof(MOUSEKEYS),
196  &pGlobalData->mouseKeys,
198  return TRUE;
199  }
200  break;
201  }
202 
203  return FALSE;
204 }
static UINT nSpeedArray[SPEEDTICKS]
Definition: mouse.c:15
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define SPI_SETMOUSEKEYS
Definition: winuser.h:1386
struct _PSHNOTIFY * LPPSHNOTIFY
#define IDC_MOUSE_BOX
Definition: resource.h:49
#define MKF_REPLACENUMBERS
Definition: winuser.h:2109
#define GWL_ID
Definition: winuser.h:853
#define CALLBACK
Definition: compat.h:27
#define TBM_SETRANGE
Definition: commctrl.h:2009
#define SystemParametersInfo
Definition: winuser.h:5724
#define MKF_HOTKEYACTIVE
Definition: winuser.h:2104
#define MKF_INDICATOR
Definition: winuser.h:2106
#define TBM_SETPOS
Definition: commctrl.h:2008
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5708
#define PSN_APPLY
Definition: prsht.h:117
int32_t INT_PTR
Definition: typedefs.h:62
#define IDC_MOUSE_BUTTON
Definition: resource.h:50
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
INT_PTR CALLBACK MousePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: mouse.c:142
#define IDD_MOUSEKEYSOPTIONS
Definition: resource.h:19
#define IDC_MOUSEKEYS_OFF_RADIO
Definition: resource.h:98
UINT code
Definition: winuser.h:3112
NMHDR hdr
Definition: prsht.h:312
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 TBM_GETPOS
Definition: commctrl.h:2003
#define ACCELTICKS
Definition: mouse.c:13
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define LPPROPSHEETPAGE
Definition: prsht.h:372
smooth NULL
Definition: ftsmooth.c:416
#define IDC_MOUSEKEYS_ACCEL_TRACK
Definition: resource.h:95
LONG_PTR LPARAM
Definition: windef.h:208
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define IDC_MOUSEKEYS_SPEED_CHECK
Definition: resource.h:96
#define IDC_MOUSEKEYS_ACTIVATE_CHECK
Definition: resource.h:93
#define DialogBoxParam
Definition: winuser.h:5630
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1716
#define BST_UNCHECKED
Definition: winuser.h:199
#define SPEEDTICKS
Definition: mouse.c:12
#define IDC_MOUSEKEYS_SPEED_TRACK
Definition: resource.h:94
HWND WINAPI GetParent(_In_ HWND)
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
INT_PTR CALLBACK MouseKeysDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: mouse.c:19
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define WM_HSCROLL
Definition: winuser.h:1719
#define SPIF_SENDCHANGE
Definition: winuser.h:1555
#define IDC_MOUSEKEYS_STATUS_CHECK
Definition: resource.h:99
#define BST_CHECKED
Definition: winuser.h:197
struct _GLOBAL_DATA * PGLOBAL_DATA
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
#define IDC_MOUSEKEYS_ON_RADIO
Definition: resource.h:97
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
#define MKF_MODIFIERS
Definition: winuser.h:2108
#define MKF_MOUSEKEYSON
Definition: winuser.h:2107