ReactOS  0.4.14-dev-57-g333b8f1
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 {
19  TCHAR szValue[128];
20  DWORD dwDisposition;
22  HKEY hKey;
23  LONG lError;
24  INT i;
25 
27  _T("Control Panel\\Appearance\\Schemes"),
28  0,
29  NULL,
32  NULL,
33  &hKey,
34  &dwDisposition);
35  if (lError != ERROR_SUCCESS)
36  return;
37 
38  for (i = 0; ; i++)
39  {
40  dwLength = 128;
41  lError = RegEnumValue(hKey,
42  i,
43  szValue,
44  &dwLength, NULL, NULL, NULL, NULL);
45  if (lError == ERROR_NO_MORE_ITEMS)
46  break;
47 
50  0,
51  (LPARAM)szValue);
52  }
53 
54  RegCloseKey(hKey);
55 }
56 
57 
60  UINT uMsg,
61  WPARAM wParam,
62  LPARAM lParam)
63 {
64  PGLOBAL_DATA pGlobalData;
65 
66  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
67 
68  switch (uMsg)
69  {
70  case WM_INITDIALOG:
71  pGlobalData = (PGLOBAL_DATA)lParam;
72  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
73 
74  CheckDlgButton(hwndDlg,
76  pGlobalData->highContrast.dwFlags & HCF_HOTKEYACTIVE ? BST_CHECKED : BST_UNCHECKED);
77 
79 
80  SendDlgItemMessage(hwndDlg,
83  (WPARAM)-1,
84  (LPARAM)pGlobalData->highContrast.lpszDefaultScheme);
85  break;
86 
87  case WM_COMMAND:
88  switch (LOWORD(wParam))
89  {
91  pGlobalData->highContrast.dwFlags ^= HCF_HOTKEYACTIVE;
92  break;
93 
94  case IDC_CONTRAST_COMBO:
95  if (HIWORD(wParam) == CBN_SELCHANGE)
96  {
97  INT nSel;
98 
99  nSel = SendDlgItemMessage(hwndDlg, IDC_CONTRAST_COMBO,
100  CB_GETCURSEL, 0, 0);
102  CB_GETLBTEXT, nSel,
103  (LPARAM)pGlobalData->highContrast.lpszDefaultScheme);
104  }
105  break;
106 
107  case IDOK:
108  EndDialog(hwndDlg, TRUE);
109  break;
110 
111  case IDCANCEL:
112  EndDialog(hwndDlg, FALSE);
113  break;
114 
115  default:
116  break;
117  }
118  break;
119  }
120 
121  return FALSE;
122 }
123 
124 
125 /* Property page dialog callback */
128  UINT uMsg,
129  WPARAM wParam,
130  LPARAM lParam)
131 {
132  PGLOBAL_DATA pGlobalData;
133  LPPSHNOTIFY lppsn;
134  INT i;
135 
136  pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
137 
138  switch (uMsg)
139  {
140  case WM_INITDIALOG:
141  pGlobalData = (PGLOBAL_DATA)((LPPROPSHEETPAGE)lParam)->lParam;
142  if (pGlobalData == NULL)
143  return FALSE;
144 
145  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
146 
147  pGlobalData->fShowCaret = TRUE;
148  GetWindowRect(GetDlgItem(hwndDlg, IDC_CURSOR_WIDTH_TEXT), &pGlobalData->rcCaret);
149  ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.left);
150  ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.right);
151  CopyRect(&pGlobalData->rcOldCaret, &pGlobalData->rcCaret);
152 
153  pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth;
154 
155  /* Set the checkbox */
156  CheckDlgButton(hwndDlg,
158  pGlobalData->highContrast.dwFlags & HCF_HIGHCONTRASTON ? BST_CHECKED : BST_UNCHECKED);
159 
161  SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(12 - (pGlobalData->uCaretBlinkTime / 100)));
162 
164  SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->uCaretWidth - 1));
165 
166  /* Start the blink timer */
167  SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL);
168  return TRUE;
169 
170  case WM_COMMAND:
171  switch (LOWORD(wParam))
172  {
173  case IDC_CONTRAST_BOX:
174  pGlobalData->highContrast.dwFlags ^= HCF_HIGHCONTRASTON;
175  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
176  break;
177 
178  case IDC_CONTRAST_BUTTON:
181  hwndDlg,
183  (LPARAM)pGlobalData))
184  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
185  break;
186 
187  default:
188  break;
189  }
190  break;
191 
192  case WM_HSCROLL:
193  switch (GetWindowLongPtr((HWND) lParam, GWL_ID))
194  {
197  pGlobalData->uCaretBlinkTime = (12 - (UINT)i) * 100;
198  KillTimer(hwndDlg, ID_BLINK_TIMER);
199  SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL);
200  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
201  break;
202 
205  pGlobalData->uCaretWidth = (UINT)i + 1;
206  pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth;
207  if (pGlobalData->fShowCaret)
208  {
209  HDC hDC = GetDC(hwndDlg);
210  HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
211  FillRect(hDC, &pGlobalData->rcCaret, hBrush);
212  DeleteObject(hBrush);
213  ReleaseDC(hwndDlg, hDC);
214  }
215  else
216  {
217  InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE);
218  }
219  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
220  break;
221  }
222  break;
223 
224  case WM_TIMER:
225  if (wParam == ID_BLINK_TIMER)
226  {
227  if (pGlobalData->fShowCaret)
228  {
229  HDC hDC = GetDC(hwndDlg);
230  HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
231  FillRect(hDC, &pGlobalData->rcCaret, hBrush);
232  DeleteObject(hBrush);
233  ReleaseDC(hwndDlg, hDC);
234  }
235  else
236  {
237  InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE);
238  }
239 
240  pGlobalData->fShowCaret = !pGlobalData->fShowCaret;
241  }
242  break;
243 
244  case WM_NOTIFY:
245  lppsn = (LPPSHNOTIFY)lParam;
246  if (lppsn->hdr.code == PSN_APPLY)
247  {
248  SetCaretBlinkTime(pGlobalData->uCaretBlinkTime);
249  SystemParametersInfo(SPI_SETCARETWIDTH,
250  0,
251  IntToPtr(pGlobalData->uCaretWidth),
253  SystemParametersInfo(SPI_SETHIGHCONTRAST,
254  sizeof(HIGHCONTRAST),
255  &pGlobalData->highContrast,
257  return TRUE;
258  }
259  break;
260 
261  case WM_DESTROY:
262  KillTimer(hwndDlg, ID_BLINK_TIMER);
263  break;
264  }
265 
266  return FALSE;
267 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#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 ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
struct _PSHNOTIFY * LPPSHNOTIFY
HDC WINAPI GetDC(_In_opt_ HWND)
#define CB_GETLBTEXT
Definition: winuser.h:1934
#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:27
#define TBM_SETRANGE
Definition: commctrl.h:2009
#define SystemParametersInfo
Definition: winuser.h:5759
#define IDC_CONTRAST_BUTTON
Definition: resource.h:48
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#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:5743
#define PSN_APPLY
Definition: prsht.h:117
int32_t INT_PTR
Definition: typedefs.h:62
#define IDC_CONTRAST_BOX
Definition: resource.h:47
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1925
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
UINT code
Definition: winuser.h:3133
#define HCF_HIGHCONTRASTON
Definition: winuser.h:2116
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define TBM_GETPOS
Definition: commctrl.h:2003
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CB_ADDSTRING
Definition: winuser.h:1918
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define LPPROPSHEETPAGE
Definition: prsht.h:372
smooth NULL
Definition: ftsmooth.c:416
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:1591
#define IntToPtr(i)
Definition: basetsd.h:89
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static DWORD DWORD * dwLength
Definition: fusion.c:83
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define WM_TIMER
Definition: winuser.h:1724
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DialogBoxParam
Definition: winuser.h:5665
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:1942
INT_PTR CALLBACK HighContrastDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: display.c:59
#define IDC_CONTRAST_COMBO
Definition: resource.h:88
#define WM_COMMAND
Definition: winuser.h:1722
#define BST_UNCHECKED
Definition: winuser.h:199
#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:1553
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
static VOID FillColorSchemeComboBox(HWND hwnd)
Definition: display.c:17
#define KEY_EXECUTE
Definition: nt_native.h:1037
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define WM_HSCROLL
Definition: winuser.h:1725
#define HCF_HOTKEYACTIVE
Definition: winuser.h:2118
#define SPIF_SENDCHANGE
Definition: winuser.h:1554
#define CBN_SELCHANGE
Definition: winuser.h:1961
BOOL WINAPI SetCaretBlinkTime(_In_ UINT)
#define ID_BLINK_TIMER
Definition: display.c:14
#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:5744
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define COLOR_BTNTEXT
Definition: winuser.h:923
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
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:1721
LPARAM lParam
Definition: combotst.c:139
INT_PTR CALLBACK DisplayPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: display.c:127
#define LOWORD(l)
Definition: pedump.c:82
#define RegEnumValue
Definition: winreg.h:511
#define RegCreateKeyEx
Definition: winreg.h:501
#define WM_NOTIFY
Definition: richedit.h:61
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019