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 18 INT_PTR CALLBACK 19 MouseKeysDlgProc(HWND hwndDlg, 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, 36 IDC_MOUSEKEYS_ACTIVATE_CHECK, 37 pGlobalData->mouseKeys.dwFlags & MKF_HOTKEYACTIVE ? BST_CHECKED : BST_UNCHECKED); 38 39 /* Set the number of ticks for the speed trackbar */ 40 SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_SPEED_TRACK, TBM_SETRANGE, 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 */ 51 SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_SPEED_TRACK, TBM_SETPOS, TRUE, i); 52 53 /* Set the number of ticks for the acceleration trackbar */ 54 SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_ACCEL_TRACK, TBM_SETRANGE, 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 */ 66 SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_ACCEL_TRACK, TBM_SETPOS, TRUE, i); 67 68 CheckDlgButton(hwndDlg, 69 IDC_MOUSEKEYS_SPEED_CHECK, 70 pGlobalData->mouseKeys.dwFlags & MKF_MODIFIERS ? BST_CHECKED : BST_UNCHECKED); 71 72 CheckRadioButton(hwndDlg, 73 IDC_MOUSEKEYS_ON_RADIO, 74 IDC_MOUSEKEYS_OFF_RADIO, 75 pGlobalData->mouseKeys.dwFlags & MKF_REPLACENUMBERS ? IDC_MOUSEKEYS_ON_RADIO : IDC_MOUSEKEYS_OFF_RADIO); 76 77 CheckDlgButton(hwndDlg, 78 IDC_MOUSEKEYS_STATUS_CHECK, 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 { 85 case IDC_MOUSEKEYS_SPEED_TRACK: 86 i = SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_SPEED_TRACK, TBM_GETPOS, 0, 0); 87 if (i >= 0 && i < SPEEDTICKS) 88 pGlobalData->mouseKeys.iMaxSpeed = nSpeedArray[i]; 89 break; 90 91 case IDC_MOUSEKEYS_ACCEL_TRACK: 92 i = SendDlgItemMessage(hwndDlg, IDC_MOUSEKEYS_ACCEL_TRACK, TBM_GETPOS, 0, 0); 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 { 102 case IDC_MOUSEKEYS_ACTIVATE_CHECK: 103 pGlobalData->mouseKeys.dwFlags ^= MKF_HOTKEYACTIVE; 104 break; 105 106 case IDC_MOUSEKEYS_SPEED_CHECK: 107 pGlobalData->mouseKeys.dwFlags ^= MKF_MODIFIERS; 108 break; 109 110 case IDC_MOUSEKEYS_ON_RADIO: 111 pGlobalData->mouseKeys.dwFlags |= MKF_REPLACENUMBERS; 112 break; 113 114 case IDC_MOUSEKEYS_OFF_RADIO: 115 pGlobalData->mouseKeys.dwFlags &= ~MKF_REPLACENUMBERS; 116 break; 117 118 case IDC_MOUSEKEYS_STATUS_CHECK: 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 */ 141 INT_PTR CALLBACK 142 MousePageProc(HWND hwndDlg, 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, 163 IDC_MOUSE_BOX, 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: 177 if (DialogBoxParam(hApplet, 178 MAKEINTRESOURCE(IDD_MOUSEKEYSOPTIONS), 179 hwndDlg, 180 (DLGPROC)MouseKeysDlgProc, 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 { 194 SystemParametersInfo(SPI_SETMOUSEKEYS, 195 sizeof(MOUSEKEYS), 196 &pGlobalData->mouseKeys, 197 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE /*0*/); 198 return TRUE; 199 } 200 break; 201 } 202 203 return FALSE; 204 } 205