ReactOS  0.4.15-dev-5487-ge7bbbf0
display.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/display.c
5  * PURPOSE: Display-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 #include <wingdi.h>
13 
14 #define ID_BLINK_TIMER 346
15 
16 static VOID
18  _In_ UINT uCaretBlinkTime)
19 {
20  HKEY hKey;
21  WCHAR szBuffer[12];
22 
24  L"Control Panel\\Desktop",
25  0, KEY_SET_VALUE,
26  &hKey) != ERROR_SUCCESS)
27  {
28  return;
29  }
30 
31  wsprintf(szBuffer, L"%d", uCaretBlinkTime);
32 
33  RegSetValueExW(hKey, L"CursorBlinkRate",
34  0, REG_SZ,
35  (CONST BYTE*)szBuffer,
36  (wcslen(szBuffer) + 1) * sizeof(WCHAR));
37 
39 }
40 
41 static VOID
43 {
44  TCHAR szValue[128];
45  DWORD dwDisposition;
47  HKEY hKey;
48  LONG lError;
49  INT i;
50 
52  _T("Control Panel\\Appearance\\Schemes"),
53  0,
54  NULL,
57  NULL,
58  &hKey,
59  &dwDisposition);
60  if (lError != ERROR_SUCCESS)
61  return;
62 
63  for (i = 0; ; i++)
64  {
65  dwLength = 128;
66  lError = RegEnumValue(hKey,
67  i,
68  szValue,
69  &dwLength, NULL, NULL, NULL, NULL);
70  if (lError == ERROR_NO_MORE_ITEMS)
71  break;
72 
75  0,
76  (LPARAM)szValue);
77  }
78 
80 }
81 
82 
85  UINT uMsg,
86  WPARAM wParam,
87  LPARAM lParam)
88 {
89  PGLOBAL_DATA pGlobalData;
90 
91  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
92 
93  switch (uMsg)
94  {
95  case WM_INITDIALOG:
96  pGlobalData = (PGLOBAL_DATA)lParam;
97  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
98 
99  CheckDlgButton(hwndDlg,
101  pGlobalData->highContrast.dwFlags & HCF_HOTKEYACTIVE ? BST_CHECKED : BST_UNCHECKED);
102 
104 
105  SendDlgItemMessage(hwndDlg,
108  (WPARAM)-1,
109  (LPARAM)pGlobalData->highContrast.lpszDefaultScheme);
110  break;
111 
112  case WM_COMMAND:
113  switch (LOWORD(wParam))
114  {
116  pGlobalData->highContrast.dwFlags ^= HCF_HOTKEYACTIVE;
117  break;
118 
119  case IDC_CONTRAST_COMBO:
120  if (HIWORD(wParam) == CBN_SELCHANGE)
121  {
122  INT nSel;
123 
124  nSel = SendDlgItemMessage(hwndDlg, IDC_CONTRAST_COMBO,
125  CB_GETCURSEL, 0, 0);
127  CB_GETLBTEXT, nSel,
128  (LPARAM)pGlobalData->highContrast.lpszDefaultScheme);
129  }
130  break;
131 
132  case IDOK:
133  EndDialog(hwndDlg, TRUE);
134  break;
135 
136  case IDCANCEL:
137  EndDialog(hwndDlg, FALSE);
138  break;
139 
140  default:
141  break;
142  }
143  break;
144  }
145 
146  return FALSE;
147 }
148 
149 
150 /* Property page dialog callback */
153  UINT uMsg,
154  WPARAM wParam,
155  LPARAM lParam)
156 {
157  PGLOBAL_DATA pGlobalData;
158  LPPSHNOTIFY lppsn;
159  INT i;
160 
161  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
162 
163  switch (uMsg)
164  {
165  case WM_INITDIALOG:
166  pGlobalData = (PGLOBAL_DATA)((LPPROPSHEETPAGE)lParam)->lParam;
167  if (pGlobalData == NULL)
168  return FALSE;
169 
170  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
171 
172  pGlobalData->fShowCaret = TRUE;
173  GetWindowRect(GetDlgItem(hwndDlg, IDC_CURSOR_WIDTH_TEXT), &pGlobalData->rcCaret);
174  ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.left);
175  ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.right);
176  CopyRect(&pGlobalData->rcOldCaret, &pGlobalData->rcCaret);
177 
178  pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth;
179 
180  /* Set the checkbox */
181  CheckDlgButton(hwndDlg,
183  pGlobalData->highContrast.dwFlags & HCF_HIGHCONTRASTON ? BST_CHECKED : BST_UNCHECKED);
184 
186  SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(12 - (pGlobalData->uCaretBlinkTime / 100)));
187 
189  SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->uCaretWidth - 1));
190 
191  /* Start the blink timer */
192  pGlobalData->uCaretBlinkTime = pGlobalData->uCaretBlinkTime >= 1200 ? -1 : pGlobalData->uCaretBlinkTime;
193  if ((INT)pGlobalData->uCaretBlinkTime > 0)
194  {
195  SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL);
196  }
197  else
198  {
199  PostMessage(hwndDlg, WM_TIMER, ID_BLINK_TIMER, 0);
200  }
201 
202  return TRUE;
203 
204  case WM_COMMAND:
205  switch (LOWORD(wParam))
206  {
207  case IDC_CONTRAST_BOX:
208  pGlobalData->highContrast.dwFlags ^= HCF_HIGHCONTRASTON;
209  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
210  break;
211 
212  case IDC_CONTRAST_BUTTON:
215  hwndDlg,
217  (LPARAM)pGlobalData))
218  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
219  break;
220 
221  default:
222  break;
223  }
224  break;
225 
226  case WM_HSCROLL:
227  switch (GetWindowLongPtr((HWND) lParam, GWL_ID))
228  {
231  pGlobalData->uCaretBlinkTime = (12 - (UINT)i) * 100;
232  KillTimer(hwndDlg, ID_BLINK_TIMER);
233  pGlobalData->uCaretBlinkTime = pGlobalData->uCaretBlinkTime >= 1200 ? -1 : pGlobalData->uCaretBlinkTime;
234  if ((INT)pGlobalData->uCaretBlinkTime > 0)
235  {
236  SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL);
237  }
238  else if (pGlobalData->fShowCaret)
239  {
240  SendMessage(hwndDlg, WM_TIMER, ID_BLINK_TIMER, 0);
241  }
242  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
243  break;
244 
247  pGlobalData->uCaretWidth = (UINT)i + 1;
248  pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth;
249  if (pGlobalData->fShowCaret)
250  {
251  HDC hDC = GetDC(hwndDlg);
252  HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
253  FillRect(hDC, &pGlobalData->rcCaret, hBrush);
254  ReleaseDC(hwndDlg, hDC);
255  }
256  else
257  {
258  InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE);
259  }
260  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
261  break;
262  }
263  break;
264 
265  case WM_TIMER:
266  if (wParam == ID_BLINK_TIMER)
267  {
268  if (pGlobalData->fShowCaret)
269  {
270  HDC hDC = GetDC(hwndDlg);
271  HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
272  FillRect(hDC, &pGlobalData->rcCaret, hBrush);
273  ReleaseDC(hwndDlg, hDC);
274  }
275  else
276  {
277  InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE);
278  }
279 
280  pGlobalData->fShowCaret = !pGlobalData->fShowCaret;
281  }
282  break;
283 
284  case WM_NOTIFY:
285  lppsn = (LPPSHNOTIFY)lParam;
286  if (lppsn->hdr.code == PSN_APPLY)
287  {
288  if (SetCaretBlinkTime(pGlobalData->uCaretBlinkTime))
289  {
290  UpdateCaretBlinkTimeReg(pGlobalData->uCaretBlinkTime);
291  }
292 
293  SystemParametersInfo(SPI_SETCARETWIDTH,
294  0,
295  IntToPtr(pGlobalData->uCaretWidth),
297  SystemParametersInfo(SPI_SETHIGHCONTRAST,
298  sizeof(HIGHCONTRAST),
299  &pGlobalData->highContrast,
301  return TRUE;
302  }
303  break;
304 
305  case WM_DESTROY:
306  KillTimer(hwndDlg, ID_BLINK_TIMER);
307  break;
308  }
309 
310  return FALSE;
311 }
static VOID UpdateCaretBlinkTimeReg(_In_ UINT uCaretBlinkTime)
Definition: display.c:17
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDOK
Definition: winuser.h:824
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
struct _PSHNOTIFY * LPPSHNOTIFY
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define CB_GETLBTEXT
Definition: winuser.h:1942
#define GWL_ID
Definition: winuser.h:853
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:35
#define TBM_SETRANGE
Definition: commctrl.h:2037
#define SystemParametersInfo
Definition: winuser.h:5848
#define IDC_CONTRAST_BUTTON
Definition: resource.h:48
#define TBM_SETPOS
Definition: commctrl.h:2036
HINSTANCE hApplet
Definition: access.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5832
#define PSN_APPLY
Definition: prsht.h:117
int32_t INT_PTR
Definition: typedefs.h:64
#define IDC_CONTRAST_BOX
Definition: resource.h:47
int32_t INT
Definition: typedefs.h:58
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1933
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
UINT code
Definition: winuser.h:3149
#define HCF_HIGHCONTRASTON
Definition: winuser.h:2124
NMHDR hdr
Definition: prsht.h:330
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define TBM_GETPOS
Definition: commctrl.h:2031
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CB_ADDSTRING
Definition: winuser.h:1926
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define _In_
Definition: ms_sal.h:308
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1599
#define IntToPtr(i)
Definition: basetsd.h:89
#define PostMessage
Definition: winuser.h:5822
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define WM_TIMER
Definition: winuser.h:1732
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DialogBoxParam
Definition: winuser.h:5754
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define IDC_CURSOR_BLINK_TRACK
Definition: resource.h:89
#define DWLP_USER
Definition: winuser.h:866
#define CB_SELECTSTRING
Definition: winuser.h:1950
INT_PTR CALLBACK HighContrastDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: display.c:84
#define IDC_CONTRAST_COMBO
Definition: resource.h:88
#define WM_COMMAND
Definition: winuser.h:1730
#define BST_UNCHECKED
Definition: winuser.h:199
unsigned char BYTE
Definition: xxhash.c:193
#define IDD_CONTRASTOPTIONS
Definition: resource.h:18
static HDC hDC
Definition: 3dtext.c:33
#define IDC_CURSOR_WIDTH_TRACK
Definition: resource.h:90
HWND WINAPI GetParent(_In_ HWND)
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1561
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
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
static VOID FillColorSchemeComboBox(HWND hwnd)
Definition: display.c:42
#define KEY_EXECUTE
Definition: nt_native.h:1037
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define WM_HSCROLL
Definition: winuser.h:1733
#define HCF_HOTKEYACTIVE
Definition: winuser.h:2126
#define SPIF_SENDCHANGE
Definition: winuser.h:1562
#define CBN_SELCHANGE
Definition: winuser.h:1969
BOOL WINAPI SetCaretBlinkTime(_In_ UINT)
#define ID_BLINK_TIMER
Definition: display.c:14
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define BST_CHECKED
Definition: winuser.h:197
#define IDC_CONTRAST_ACTIVATE_CHECK
Definition: resource.h:87
struct _GLOBAL_DATA * PGLOBAL_DATA
#define SendMessage
Definition: winuser.h:5833
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
#define HIWORD(l)
Definition: typedefs.h:247
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define COLOR_BTNTEXT
Definition: winuser.h:927
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
#define wsprintf
Definition: winuser.h:5855
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define IDC_CURSOR_WIDTH_TEXT
Definition: resource.h:91
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
INT_PTR CALLBACK DisplayPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: display.c:152
#define LOWORD(l)
Definition: pedump.c:82
#define RegEnumValue
Definition: winreg.h:511
#define CONST
Definition: pedump.c:81
#define RegCloseKey(hKey)
Definition: registry.h:47
#define RegCreateKeyEx
Definition: winreg.h:501
#define WM_NOTIFY
Definition: richedit.h:61
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_SZ
Definition: layer.c:22