2013-03-16 20:25:38 +00:00
|
|
|
/*
|
2007-08-19 16:11:04 +00:00
|
|
|
* PROJECT: ReactOS Accessibility Control Panel
|
2006-04-07 13:03:59 +00:00
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
2007-08-11 20:53:52 +00:00
|
|
|
* FILE: dll/cpl/access/display.c
|
2007-08-19 16:11:04 +00:00
|
|
|
* PURPOSE: Display-related accessibility settings
|
2013-09-15 13:06:05 +00:00
|
|
|
* COPYRIGHT: Copyright 2004 Johannes Anderwald (johannes.anderwald@reactos.org)
|
2007-08-19 16:11:04 +00:00
|
|
|
* Copyright 2007 Eric Kohl
|
2004-06-30 12:16:27 +00:00
|
|
|
*/
|
2007-08-19 16:11:04 +00:00
|
|
|
|
2004-06-30 12:16:27 +00:00
|
|
|
#include "access.h"
|
|
|
|
|
2014-01-13 13:18:29 +00:00
|
|
|
#include <wingdi.h>
|
2007-08-11 20:53:52 +00:00
|
|
|
|
2007-08-26 19:58:13 +00:00
|
|
|
#define ID_BLINK_TIMER 346
|
|
|
|
|
2007-08-11 20:53:52 +00:00
|
|
|
static VOID
|
|
|
|
FillColorSchemeComboBox(HWND hwnd)
|
|
|
|
{
|
|
|
|
TCHAR szValue[128];
|
|
|
|
DWORD dwDisposition;
|
|
|
|
DWORD dwLength;
|
|
|
|
HKEY hKey;
|
|
|
|
LONG lError;
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
lError = RegCreateKeyEx(HKEY_CURRENT_USER,
|
|
|
|
_T("Control Panel\\Appearance\\Schemes"),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_NON_VOLATILE,
|
|
|
|
KEY_ENUMERATE_SUB_KEYS | KEY_EXECUTE | KEY_QUERY_VALUE,
|
|
|
|
NULL,
|
|
|
|
&hKey,
|
|
|
|
&dwDisposition);
|
|
|
|
if (lError != ERROR_SUCCESS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; ; i++)
|
|
|
|
{
|
|
|
|
dwLength = 128;
|
|
|
|
lError = RegEnumValue(hKey,
|
|
|
|
i,
|
|
|
|
szValue,
|
|
|
|
&dwLength, NULL, NULL, NULL, NULL);
|
|
|
|
if (lError == ERROR_NO_MORE_ITEMS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
SendMessage(hwnd,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)szValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
HighContrastDlgProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
PGLOBAL_DATA pGlobalData;
|
|
|
|
|
|
|
|
pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
pGlobalData = (PGLOBAL_DATA)lParam;
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
|
|
|
|
|
|
|
CheckDlgButton(hwndDlg,
|
|
|
|
IDC_CONTRAST_ACTIVATE_CHECK,
|
|
|
|
pGlobalData->highContrast.dwFlags & HCF_HOTKEYACTIVE ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
|
|
|
|
FillColorSchemeComboBox(GetDlgItem(hwndDlg, IDC_CONTRAST_COMBO));
|
|
|
|
|
|
|
|
SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_CONTRAST_COMBO,
|
|
|
|
CB_SELECTSTRING,
|
2008-10-25 17:32:54 +00:00
|
|
|
(WPARAM)-1,
|
2007-08-11 20:53:52 +00:00
|
|
|
(LPARAM)pGlobalData->highContrast.lpszDefaultScheme);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDC_CONTRAST_ACTIVATE_CHECK:
|
|
|
|
pGlobalData->highContrast.dwFlags ^= HCF_HOTKEYACTIVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_CONTRAST_COMBO:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
INT nSel;
|
|
|
|
|
|
|
|
nSel = SendDlgItemMessage(hwndDlg, IDC_CONTRAST_COMBO,
|
|
|
|
CB_GETCURSEL, 0, 0);
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_CONTRAST_COMBO,
|
|
|
|
CB_GETLBTEXT, nSel,
|
|
|
|
(LPARAM)pGlobalData->highContrast.lpszDefaultScheme);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hwndDlg, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hwndDlg, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-30 12:16:27 +00:00
|
|
|
/* Property page dialog callback */
|
2004-10-11 21:08:06 +00:00
|
|
|
INT_PTR CALLBACK
|
2007-05-01 13:55:11 +00:00
|
|
|
DisplayPageProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
2004-06-30 12:16:27 +00:00
|
|
|
{
|
2007-08-11 20:53:52 +00:00
|
|
|
PGLOBAL_DATA pGlobalData;
|
|
|
|
LPPSHNOTIFY lppsn;
|
2007-08-26 19:58:13 +00:00
|
|
|
INT i;
|
2007-08-11 20:53:52 +00:00
|
|
|
|
|
|
|
pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
2007-05-01 13:55:11 +00:00
|
|
|
|
|
|
|
switch (uMsg)
|
2004-06-30 12:16:27 +00:00
|
|
|
{
|
2007-05-01 13:55:11 +00:00
|
|
|
case WM_INITDIALOG:
|
2007-09-17 22:29:35 +00:00
|
|
|
pGlobalData = (PGLOBAL_DATA)((LPPROPSHEETPAGE)lParam)->lParam;
|
2007-08-11 20:53:52 +00:00
|
|
|
if (pGlobalData == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
|
|
|
|
2007-08-26 19:58:13 +00:00
|
|
|
pGlobalData->fShowCaret = TRUE;
|
|
|
|
GetWindowRect(GetDlgItem(hwndDlg, IDC_CURSOR_WIDTH_TEXT), &pGlobalData->rcCaret);
|
|
|
|
ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.left);
|
|
|
|
ScreenToClient(hwndDlg, (LPPOINT)&pGlobalData->rcCaret.right);
|
|
|
|
CopyRect(&pGlobalData->rcOldCaret, &pGlobalData->rcCaret);
|
|
|
|
|
|
|
|
pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth;
|
|
|
|
|
2007-08-11 20:53:52 +00:00
|
|
|
/* Set the checkbox */
|
|
|
|
CheckDlgButton(hwndDlg,
|
|
|
|
IDC_CONTRAST_BOX,
|
|
|
|
pGlobalData->highContrast.dwFlags & HCF_HIGHCONTRASTON ? BST_CHECKED : BST_UNCHECKED);
|
2007-08-26 19:58:13 +00:00
|
|
|
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 10));
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(12 - (pGlobalData->uCaretBlinkTime / 100)));
|
|
|
|
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 19));
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(pGlobalData->uCaretWidth - 1));
|
|
|
|
|
|
|
|
/* Start the blink timer */
|
|
|
|
SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL);
|
2007-08-11 20:53:52 +00:00
|
|
|
return TRUE;
|
2007-05-01 13:55:11 +00:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDC_CONTRAST_BOX:
|
2007-08-11 20:53:52 +00:00
|
|
|
pGlobalData->highContrast.dwFlags ^= HCF_HIGHCONTRASTON;
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
2007-05-01 13:55:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_CONTRAST_BUTTON:
|
2007-08-11 20:53:52 +00:00
|
|
|
if (DialogBoxParam(hApplet,
|
|
|
|
MAKEINTRESOURCE(IDD_CONTRASTOPTIONS),
|
|
|
|
hwndDlg,
|
|
|
|
(DLGPROC)HighContrastDlgProc,
|
|
|
|
(LPARAM)pGlobalData))
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
2007-05-01 13:55:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2007-08-11 20:53:52 +00:00
|
|
|
|
2007-08-26 19:58:13 +00:00
|
|
|
case WM_HSCROLL:
|
2009-05-09 12:27:40 +00:00
|
|
|
switch (GetWindowLongPtr((HWND) lParam, GWL_ID))
|
2007-08-26 19:58:13 +00:00
|
|
|
{
|
|
|
|
case IDC_CURSOR_BLINK_TRACK:
|
|
|
|
i = SendDlgItemMessage(hwndDlg, IDC_CURSOR_BLINK_TRACK, TBM_GETPOS, 0, 0);
|
|
|
|
pGlobalData->uCaretBlinkTime = (12 - (UINT)i) * 100;
|
|
|
|
KillTimer(hwndDlg, ID_BLINK_TIMER);
|
|
|
|
SetTimer(hwndDlg, ID_BLINK_TIMER, pGlobalData->uCaretBlinkTime, NULL);
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_CURSOR_WIDTH_TRACK:
|
|
|
|
i = SendDlgItemMessage(hwndDlg, IDC_CURSOR_WIDTH_TRACK, TBM_GETPOS, 0, 0);
|
|
|
|
pGlobalData->uCaretWidth = (UINT)i + 1;
|
|
|
|
pGlobalData->rcCaret.right = pGlobalData->rcCaret.left + pGlobalData->uCaretWidth;
|
|
|
|
if (pGlobalData->fShowCaret)
|
|
|
|
{
|
|
|
|
HDC hDC = GetDC(hwndDlg);
|
|
|
|
HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
|
|
|
|
FillRect(hDC, &pGlobalData->rcCaret, hBrush);
|
|
|
|
DeleteObject(hBrush);
|
|
|
|
ReleaseDC(hwndDlg, hDC);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE);
|
|
|
|
}
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_TIMER:
|
|
|
|
if (wParam == ID_BLINK_TIMER)
|
|
|
|
{
|
|
|
|
if (pGlobalData->fShowCaret)
|
|
|
|
{
|
|
|
|
HDC hDC = GetDC(hwndDlg);
|
|
|
|
HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
|
|
|
|
FillRect(hDC, &pGlobalData->rcCaret, hBrush);
|
|
|
|
DeleteObject(hBrush);
|
|
|
|
ReleaseDC(hwndDlg, hDC);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InvalidateRect(hwndDlg, &pGlobalData->rcOldCaret, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
pGlobalData->fShowCaret = !pGlobalData->fShowCaret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-08-11 20:53:52 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
lppsn = (LPPSHNOTIFY)lParam;
|
|
|
|
if (lppsn->hdr.code == PSN_APPLY)
|
|
|
|
{
|
2007-08-26 19:58:13 +00:00
|
|
|
SetCaretBlinkTime(pGlobalData->uCaretBlinkTime);
|
|
|
|
SystemParametersInfo(SPI_SETCARETWIDTH,
|
|
|
|
0,
|
2009-04-29 22:20:59 +00:00
|
|
|
IntToPtr(pGlobalData->uCaretWidth),
|
2007-08-26 19:58:13 +00:00
|
|
|
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE /*0*/);
|
2007-08-11 20:53:52 +00:00
|
|
|
SystemParametersInfo(SPI_SETHIGHCONTRAST,
|
|
|
|
sizeof(HIGHCONTRAST),
|
|
|
|
&pGlobalData->highContrast,
|
|
|
|
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE /*0*/);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
2007-08-26 19:58:13 +00:00
|
|
|
KillTimer(hwndDlg, ID_BLINK_TIMER);
|
2007-08-11 20:53:52 +00:00
|
|
|
break;
|
2004-06-30 12:16:27 +00:00
|
|
|
}
|
2007-05-01 13:55:11 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2004-06-30 12:16:27 +00:00
|
|
|
}
|