ReactOS  0.4.15-dev-1197-g8081ba9
keyboard.c File Reference
#include "main.h"
Include dependency graph for keyboard.c:

Go to the source code of this file.

Classes

struct  _SPEED_DATA
 

Macros

#define ID_BLINK_TIMER   345
 

Typedefs

typedef struct _SPEED_DATA SPEED_DATA
 
typedef struct _SPEED_DATAPSPEED_DATA
 

Functions

static INT_PTR CALLBACK KeyboardSpeedProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static INT_PTR CALLBACK KeybHardwareProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam)
 
LONG APIENTRY KeyboardApplet (HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ ID_BLINK_TIMER

#define ID_BLINK_TIMER   345

Definition at line 28 of file keyboard.c.

Typedef Documentation

◆ PSPEED_DATA

◆ SPEED_DATA

Function Documentation

◆ KeybHardwareProc()

static INT_PTR CALLBACK KeybHardwareProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 260 of file keyboard.c.

264 {
265  GUID Guids[1];
266  Guids[0] = GUID_DEVCLASS_KEYBOARD;
267 
270 
271  switch(uMsg)
272  {
273  case WM_INITDIALOG:
274  /* Create the hardware page */
276  Guids,
277  sizeof(Guids) / sizeof(Guids[0]),
279  break;
280  }
281 
282  return FALSE;
283 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
HWND WINAPI DeviceCreateHardwarePageEx(HWND hWndParent, LPGUID lpGuids, UINT uNumberOfGuids, HWPAGE_DISPLAYMODE DisplayMode)
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139

Referenced by KeyboardApplet().

◆ KeyboardApplet()

LONG APIENTRY KeyboardApplet ( HWND  hwnd,
UINT  uMsg,
LPARAM  wParam,
LPARAM  lParam 
)

Definition at line 303 of file keyboard.c.

304 {
306  PROPSHEETHEADER psh;
307  HPSXA hpsxa;
308  TCHAR szCaption[256];
309  INT nPage = 0;
310  LONG ret;
311 
316 
317  if (uMsg == CPL_STARTWPARMSW && lParam != 0)
318  nPage = _wtoi((PWSTR)lParam);
319 
320  LoadString(hApplet, IDS_CPLNAME_2, szCaption, sizeof(szCaption) / sizeof(TCHAR));
321 
322  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
323  psh.dwSize = sizeof(PROPSHEETHEADER);
324  psh.dwFlags = PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
325  psh.hwndParent = hwnd;
326  psh.hInstance = hApplet;
327  psh.pszIcon = MAKEINTRESOURCE(IDC_CPLICON_2);
328  psh.pszCaption = szCaption;
329  psh.nStartPage = 0;
330  psh.phpage = hpsp;
331  psh.pfnCallback = PropSheetProc;
332 
333  /* Load additional pages provided by shell extensions */
335 
336  /* NOTE: The speed page (CPLPAGE_KEYBOARD_SPEED) cannot be replaced by
337  shell extensions since Win2k! */
340 
341  if (hpsxa != NULL)
343 
344  if (nPage != 0 && nPage <= psh.nPages)
345  psh.nStartPage = nPage;
346 
347  ret = (LONG)(PropertySheet(&psh) != -1);
348 
349  if (hpsxa != NULL)
351 
352  return ret;
353 }
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2162
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1984
uint16_t * PWSTR
Definition: typedefs.h:56
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
#define ZeroMemory
Definition: winbase.h:1648
HINSTANCE hApplet
Definition: access.c:17
#define PSH_USECALLBACK
Definition: prsht.h:48
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
#define MAX_CPL_PAGES
Definition: main.h:47
#define PSH_USEICONID
Definition: prsht.h:42
long LONG
Definition: pedump.c:60
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
static INT_PTR CALLBACK KeyboardSpeedProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: keyboard.c:44
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:392
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_CPLNAME_2
Definition: resource.h:36
#define IDD_KEYBSPEED
Definition: resource.h:29
char TCHAR
Definition: xmlstorage.h:189
#define PSH_PROPTITLE
Definition: prsht.h:40
#define IDD_HARDWARE
Definition: resource.h:28
#define IDC_CPLICON_2
Definition: resource.h:6
#define CPL_STARTWPARMSW
Definition: cpl.h:21
int ret
static VOID InitPropSheetPage(PROPSHEETPAGE *psp, PSERVICEPROPSHEET dlgInfo, WORD idDlg, DLGPROC DlgProc)
Definition: propsheet.c:15
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: advmon.c:13
#define TEXT(s)
Definition: k32.h:26
#define PropertySheet
Definition: prsht.h:400
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:2014
LPARAM lParam
Definition: combotst.c:139
#define LoadString
Definition: winuser.h:5794
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: keyboard.c:286
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
static INT_PTR CALLBACK KeybHardwareProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: keyboard.c:260

◆ KeyboardSpeedProc()

static INT_PTR CALLBACK KeyboardSpeedProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 44 of file keyboard.c.

48 {
49  PSPEED_DATA pSpeedData;
50 
51  pSpeedData = (PSPEED_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
52 
53  switch (uMsg)
54  {
55  case WM_INITDIALOG:
56  pSpeedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SPEED_DATA));
57  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pSpeedData);
58 
59  /* Get current keyboard delay */
61  sizeof(INT),
62  &pSpeedData->nKeyboardDelay,
63  0))
64  {
65  pSpeedData->nKeyboardDelay = 2;
66  }
67 
68  pSpeedData->nOrigKeyboardDelay = pSpeedData->nKeyboardDelay;
69 
70  /* Get current keyboard delay */
72  sizeof(DWORD),
73  &pSpeedData->dwKeyboardSpeed,
74  0))
75  {
76  pSpeedData->dwKeyboardSpeed = 31;
77  }
78 
79  pSpeedData->dwOrigKeyboardSpeed = pSpeedData->dwKeyboardSpeed;
80 
81  pSpeedData->fShowCursor = TRUE;
82  GetWindowRect(GetDlgItem(hwndDlg, IDC_TEXT_CURSOR_BLINK), &pSpeedData->rcCursor);
83  ScreenToClient(hwndDlg, (LPPOINT)&pSpeedData->rcCursor.left);
84  ScreenToClient(hwndDlg, (LPPOINT)&pSpeedData->rcCursor.right);
85 
86  /* Get the caret blink time and save its original value */
87  pSpeedData->uOrigCaretBlinkTime = GetCaretBlinkTime();
88  pSpeedData->uCaretBlinkTime = pSpeedData->uOrigCaretBlinkTime;
89 
92 
95 
97  SendDlgItemMessage(hwndDlg, IDC_SLIDER_CURSOR_BLINK, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)(12 - (pSpeedData->uCaretBlinkTime / 100)));
98 
99  /* Start the blink timer */
100  SetTimer(hwndDlg, ID_BLINK_TIMER, pSpeedData->uCaretBlinkTime, NULL);
101  break;
102 
103  case WM_HSCROLL:
104  if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_REPEAT_DELAY))
105  {
106  switch (LOWORD(wParam))
107  {
108  case TB_LINEUP:
109  case TB_LINEDOWN:
110  case TB_PAGEUP:
111  case TB_PAGEDOWN:
112  case TB_TOP:
113  case TB_BOTTOM:
114  case TB_ENDTRACK:
115  pSpeedData->nKeyboardDelay = 3 - (INT)SendDlgItemMessage(hwndDlg, IDC_SLIDER_REPEAT_DELAY, TBM_GETPOS, 0, 0);
117  pSpeedData->nKeyboardDelay,
118  0,
119  0);
120  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
121  break;
122 
123  case TB_THUMBTRACK:
124  pSpeedData->nKeyboardDelay = 3 - (INT)HIWORD(wParam);
126  pSpeedData->nKeyboardDelay,
127  0,
128  0);
129  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
130  break;
131  }
132  }
133  else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_REPEAT_RATE))
134  {
135  switch (LOWORD(wParam))
136  {
137  case TB_LINEUP:
138  case TB_LINEDOWN:
139  case TB_PAGEUP:
140  case TB_PAGEDOWN:
141  case TB_TOP:
142  case TB_BOTTOM:
143  case TB_ENDTRACK:
146  pSpeedData->dwKeyboardSpeed,
147  0,
148  0);
149  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
150  break;
151 
152  case TB_THUMBTRACK:
153  pSpeedData->dwKeyboardSpeed = (DWORD)HIWORD(wParam);
155  pSpeedData->dwKeyboardSpeed,
156  0,
157  0);
158  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
159  break;
160  }
161  }
162  else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_CURSOR_BLINK))
163  {
164  switch (LOWORD(wParam))
165  {
166  case TB_LINEUP:
167  case TB_LINEDOWN:
168  case TB_PAGEUP:
169  case TB_PAGEDOWN:
170  case TB_TOP:
171  case TB_BOTTOM:
172  case TB_ENDTRACK:
173  pSpeedData->uCaretBlinkTime = (12 - (UINT)SendDlgItemMessage(hwndDlg, IDC_SLIDER_CURSOR_BLINK, TBM_GETPOS, 0, 0)) * 100;
174  KillTimer(hwndDlg, ID_BLINK_TIMER);
175  SetTimer(hwndDlg, ID_BLINK_TIMER, pSpeedData->uCaretBlinkTime, NULL);
176  SetCaretBlinkTime(pSpeedData->uCaretBlinkTime);
177  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
178  break;
179 
180  case TB_THUMBTRACK:
181  pSpeedData->uCaretBlinkTime = (12 - (UINT)HIWORD(wParam)) * 100;
182  KillTimer(hwndDlg, ID_BLINK_TIMER);
183  SetTimer(hwndDlg, ID_BLINK_TIMER, pSpeedData->uCaretBlinkTime, NULL);
184  SetCaretBlinkTime(pSpeedData->uCaretBlinkTime);
185  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
186  break;
187  }
188  }
189  break;
190 
191  case WM_TIMER:
192  if (wParam == ID_BLINK_TIMER)
193  {
194  if (pSpeedData->fShowCursor)
195  {
196  HDC hDC = GetDC(hwndDlg);
197  HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
198  FillRect(hDC, &pSpeedData->rcCursor, hBrush);
199  DeleteObject(hBrush);
200  ReleaseDC(hwndDlg, hDC);
201  }
202  else
203  {
204  InvalidateRect(hwndDlg, &pSpeedData->rcCursor, TRUE);
205  }
206 
207  pSpeedData->fShowCursor = !pSpeedData->fShowCursor;
208  }
209  break;
210 
211  case WM_NOTIFY:
212  {
213  LPNMHDR lpnm = (LPNMHDR)lParam;
214 
215  switch(lpnm->code)
216  {
217  case PSN_APPLY:
218  /* Set the new keyboard settings */
220  pSpeedData->nKeyboardDelay,
221  0,
222  0);
224  pSpeedData->dwKeyboardSpeed,
225  0,
227  return TRUE;
228 
229  case PSN_RESET:
230  /* Restore the original settings */
233  pSpeedData->nOrigKeyboardDelay,
234  0,
235  0);
237  pSpeedData->dwOrigKeyboardSpeed,
238  0,
239  0);
240  break;
241 
242  default:
243  break;
244  }
245  }
246  break;
247 
248  case WM_DESTROY:
249  KillTimer(hwndDlg, ID_BLINK_TIMER);
250  HeapFree(GetProcessHeap(), 0, pSpeedData);
251  break;
252  }
253 
254  return FALSE;
255 }
#define TB_THUMBTRACK
Definition: commctrl.h:2074
DWORD dwOrigKeyboardSpeed
Definition: keyboard.c:35
#define TB_PAGEDOWN
Definition: commctrl.h:2072
#define IDC_SLIDER_CURSOR_BLINK
Definition: resource.h:102
#define SPI_GETKEYBOARDSPEED
Definition: winuser.h:1341
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
DWORD dwKeyboardSpeed
Definition: keyboard.c:34
#define INT
Definition: polytest.cpp:20
static HDC
Definition: imagelist.c:92
#define TBM_SETRANGE
Definition: commctrl.h:2033
#define SystemParametersInfo
Definition: winuser.h:5833
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define TBM_SETPOS
Definition: commctrl.h:2032
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5817
#define PSN_APPLY
Definition: prsht.h:117
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
#define IDC_TEXT_CURSOR_BLINK
Definition: resource.h:103
#define TB_PAGEUP
Definition: commctrl.h:2071
BOOL fShowCursor
Definition: keyboard.c:38
#define TB_LINEDOWN
Definition: commctrl.h:2070
UINT code
Definition: winuser.h:3134
#define TB_BOTTOM
Definition: commctrl.h:2076
#define SPI_SETKEYBOARDDELAY
Definition: winuser.h:1354
#define FALSE
Definition: types.h:117
#define TBM_GETPOS
Definition: commctrl.h:2027
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define MAKELONG(a, b)
Definition: typedefs.h:249
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
UINT uOrigCaretBlinkTime
Definition: keyboard.c:37
RECT rcCursor
Definition: keyboard.c:39
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
UINT WINAPI GetCaretBlinkTime(void)
Definition: ntwrapper.h:166
#define WM_DESTROY
Definition: winuser.h:1591
UINT uCaretBlinkTime
Definition: keyboard.c:36
#define SPI_GETKEYBOARDDELAY
Definition: winuser.h:1353
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SPI_SETKEYBOARDSPEED
Definition: winuser.h:1342
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#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 TB_LINEUP
Definition: commctrl.h:2069
#define TB_ENDTRACK
Definition: commctrl.h:2077
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define TB_TOP
Definition: commctrl.h:2075
#define DWLP_USER
Definition: winuser.h:866
struct _SPEED_DATA * PSPEED_DATA
INT nKeyboardDelay
Definition: keyboard.c:32
static HDC hDC
Definition: 3dtext.c:33
HWND WINAPI GetParent(_In_ HWND)
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
#define ID_BLINK_TIMER
Definition: keyboard.c:28
static DWORD
Definition: keyboard.c:34
#define PSN_RESET
Definition: prsht.h:118
#define IDC_SLIDER_REPEAT_DELAY
Definition: resource.h:98
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define WM_HSCROLL
Definition: winuser.h:1725
#define SPIF_SENDCHANGE
Definition: winuser.h:1554
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI SetCaretBlinkTime(_In_ UINT)
#define HIWORD(l)
Definition: typedefs.h:247
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define COLOR_BTNTEXT
Definition: winuser.h:923
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDC_SLIDER_REPEAT_RATE
Definition: resource.h:100
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:483
INT nOrigKeyboardDelay
Definition: keyboard.c:33
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by KeyboardApplet().

◆ PropSheetProc()

static int CALLBACK PropSheetProc ( HWND  hwndDlg,
UINT  uMsg,
LPARAM  lParam 
)
static

Definition at line 286 of file keyboard.c.

287 {
288  // NOTE: This callback is needed to set large icon correctly.
289  HICON hIcon;
290  switch (uMsg)
291  {
292  case PSCB_INITIALIZED:
293  {
295  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
296  break;
297  }
298  }
299  return 0;
300 }
static HICON
Definition: imagelist.c:84
HINSTANCE hApplet
Definition: access.c:17
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_CPLICON_2
Definition: resource.h:6
#define PSCB_INITIALIZED
Definition: prsht.h:75
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ICON_BIG
Definition: tnclass.cpp:51

Referenced by KeyboardApplet().