Change keyboard settings on-the-fly to make the preview work properly.

svn path=/trunk/; revision=26295
This commit is contained in:
Eric Kohl 2007-04-09 13:26:55 +00:00
parent 52041c5b65
commit 655f34cb87

View file

@ -39,7 +39,9 @@
typedef struct _SPEED_DATA typedef struct _SPEED_DATA
{ {
INT nKeyboardDelay; INT nKeyboardDelay;
INT nOrigKeyboardDelay;
DWORD dwKeyboardSpeed; DWORD dwKeyboardSpeed;
DWORD dwOrigKeyboardSpeed;
UINT uCaretBlinkTime; UINT uCaretBlinkTime;
UINT uOrigCaretBlinkTime; UINT uOrigCaretBlinkTime;
BOOL fShowCursor; BOOL fShowCursor;
@ -73,6 +75,8 @@ KeyboardSpeedProc(IN HWND hwndDlg,
pSpeedData->nKeyboardDelay = 2; pSpeedData->nKeyboardDelay = 2;
} }
pSpeedData->nOrigKeyboardDelay = pSpeedData->nKeyboardDelay;
/* Get current keyboard delay */ /* Get current keyboard delay */
if (!SystemParametersInfo(SPI_GETKEYBOARDSPEED, if (!SystemParametersInfo(SPI_GETKEYBOARDSPEED,
sizeof(DWORD), sizeof(DWORD),
@ -82,6 +86,8 @@ KeyboardSpeedProc(IN HWND hwndDlg,
pSpeedData->dwKeyboardSpeed = 31; pSpeedData->dwKeyboardSpeed = 31;
} }
pSpeedData->dwOrigKeyboardSpeed = pSpeedData->dwKeyboardSpeed;
pSpeedData->fShowCursor = TRUE; pSpeedData->fShowCursor = TRUE;
GetWindowRect(GetDlgItem(hwndDlg, IDC_TEXT_CURSOR_BLINK), &pSpeedData->rcCursor); GetWindowRect(GetDlgItem(hwndDlg, IDC_TEXT_CURSOR_BLINK), &pSpeedData->rcCursor);
ScreenToClient(hwndDlg, (LPPOINT)&pSpeedData->rcCursor.left); ScreenToClient(hwndDlg, (LPPOINT)&pSpeedData->rcCursor.left);
@ -117,11 +123,19 @@ KeyboardSpeedProc(IN HWND hwndDlg,
case TB_BOTTOM: case TB_BOTTOM:
case TB_ENDTRACK: case TB_ENDTRACK:
pSpeedData->nKeyboardDelay = 3 - (INT)SendDlgItemMessage(hwndDlg, IDC_SLIDER_REPEAT_DELAY, TBM_GETPOS, 0, 0); pSpeedData->nKeyboardDelay = 3 - (INT)SendDlgItemMessage(hwndDlg, IDC_SLIDER_REPEAT_DELAY, TBM_GETPOS, 0, 0);
SystemParametersInfo(SPI_SETKEYBOARDDELAY,
pSpeedData->nKeyboardDelay,
0,
0);
PropSheet_Changed(GetParent(hwndDlg), hwndDlg); PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break; break;
case TB_THUMBTRACK: case TB_THUMBTRACK:
pSpeedData->nKeyboardDelay = 3 - (INT)HIWORD(wParam); pSpeedData->nKeyboardDelay = 3 - (INT)HIWORD(wParam);
SystemParametersInfo(SPI_SETKEYBOARDDELAY,
pSpeedData->nKeyboardDelay,
0,
0);
PropSheet_Changed(GetParent(hwndDlg), hwndDlg); PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break; break;
} }
@ -138,11 +152,19 @@ KeyboardSpeedProc(IN HWND hwndDlg,
case TB_BOTTOM: case TB_BOTTOM:
case TB_ENDTRACK: case TB_ENDTRACK:
pSpeedData->dwKeyboardSpeed = (DWORD)SendDlgItemMessage(hwndDlg, IDC_SLIDER_REPEAT_RATE, TBM_GETPOS, 0, 0); pSpeedData->dwKeyboardSpeed = (DWORD)SendDlgItemMessage(hwndDlg, IDC_SLIDER_REPEAT_RATE, TBM_GETPOS, 0, 0);
SystemParametersInfo(SPI_SETKEYBOARDSPEED,
pSpeedData->dwKeyboardSpeed,
0,
0);
PropSheet_Changed(GetParent(hwndDlg), hwndDlg); PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break; break;
case TB_THUMBTRACK: case TB_THUMBTRACK:
pSpeedData->dwKeyboardSpeed = (DWORD)HIWORD(wParam); pSpeedData->dwKeyboardSpeed = (DWORD)HIWORD(wParam);
SystemParametersInfo(SPI_SETKEYBOARDSPEED,
pSpeedData->dwKeyboardSpeed,
0,
0);
PropSheet_Changed(GetParent(hwndDlg), hwndDlg); PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break; break;
} }
@ -203,11 +225,11 @@ KeyboardSpeedProc(IN HWND hwndDlg,
switch(lpnm->code) switch(lpnm->code)
{ {
case PSN_APPLY: case PSN_APPLY:
/* Set the new keyboard settings */
SystemParametersInfo(SPI_SETKEYBOARDDELAY, SystemParametersInfo(SPI_SETKEYBOARDDELAY,
pSpeedData->nKeyboardDelay, pSpeedData->nKeyboardDelay,
0, 0,
0); 0);
SystemParametersInfo(SPI_SETKEYBOARDSPEED, SystemParametersInfo(SPI_SETKEYBOARDSPEED,
pSpeedData->dwKeyboardSpeed, pSpeedData->dwKeyboardSpeed,
0, 0,
@ -215,7 +237,16 @@ KeyboardSpeedProc(IN HWND hwndDlg,
return TRUE; return TRUE;
case PSN_RESET: case PSN_RESET:
/* Restore the original settings */
SetCaretBlinkTime(pSpeedData->uOrigCaretBlinkTime); SetCaretBlinkTime(pSpeedData->uOrigCaretBlinkTime);
SystemParametersInfo(SPI_SETKEYBOARDDELAY,
pSpeedData->nOrigKeyboardDelay,
0,
0);
SystemParametersInfo(SPI_SETKEYBOARDSPEED,
pSpeedData->dwOrigKeyboardSpeed,
0,
0);
break; break;
default: default: