Author: dchapyshev
Date: Sun May 18 04:06:48 2008
New Revision: 33567
URL:
http://svn.reactos.org/svn/reactos?rev=33567&view=rev
Log:
- Implement "Advanced Key Settings" and "Change Key Sequence" dialogs
Modified:
trunk/reactos/dll/cpl/input/changekeyseq.c
trunk/reactos/dll/cpl/input/input.h
trunk/reactos/dll/cpl/input/keysettings.c
Modified: trunk/reactos/dll/cpl/input/changekeyseq.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/changekeyseq…
==============================================================================
--- trunk/reactos/dll/cpl/input/changekeyseq.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/changekeyseq.c [iso-8859-1] Sun May 18 04:06:48 2008
@@ -20,7 +20,7 @@
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Toggle"),
0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
- dwSize = sizeof(szHotkey);
+ dwSize = (1 + 1) * sizeof(TCHAR);
if (RegQueryValueEx(hKey, _T("Hotkey"), NULL, NULL,
(LPBYTE)szHotkey, &dwSize) != ERROR_SUCCESS)
{
@@ -28,7 +28,7 @@
return FALSE;
}
- dwSize = sizeof(szLangHotkey);
+ dwSize = (1 + 1) * sizeof(TCHAR);
if (RegQueryValueEx(hKey, _T("Language Hotkey"), NULL, NULL,
(LPBYTE)szLangHotkey, &dwSize) != ERROR_SUCCESS)
{
@@ -36,7 +36,7 @@
return FALSE;
}
- dwSize = sizeof(szLayoutHotkey);
+ dwSize = (1 + 1) * sizeof(TCHAR);
if (RegQueryValueEx(hKey, _T("Layout Hotkey"), NULL, NULL,
(LPBYTE)szLayoutHotkey, &dwSize) != ERROR_SUCCESS)
{
@@ -49,6 +49,66 @@
else return FALSE;
return TRUE;
+}
+
+static VOID
+SaveKeySeq(HWND hDlg)
+{
+ TCHAR szLang[1 + 1], szLayout[1 + 1];
+ HKEY hKey;
+
+ if (SendDlgItemMessage(hDlg, IDC_SWITCH_INPUT_LANG_CB, BM_GETCHECK, 0, 0) ==
BST_CHECKED)
+ {
+ if (SendDlgItemMessage(hDlg, IDC_CTRL_LANG, BM_GETCHECK, 0, 0) == BST_CHECKED)
+ _tcscpy(szLang, _T("2"));
+ else
+ _tcscpy(szLang, _T("1"));
+ }
+ else
+ {
+ _tcscpy(szLang, _T("3"));
+ }
+
+ if (SendDlgItemMessage(hDlg, IDC_SWITCH_KBLAYOUTS_CB, BM_GETCHECK, 0, 0) ==
BST_CHECKED)
+ {
+ if (SendDlgItemMessage(hDlg, IDC_CTRL_LAYOUT, BM_GETCHECK, 0, 0) == BST_CHECKED)
+ _tcscpy(szLayout, _T("2"));
+ else
+ _tcscpy(szLayout, _T("1"));
+ }
+ else
+ {
+ _tcscpy(szLayout, _T("3"));
+ }
+
+ if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Toggle"), 0,
NULL,
+ REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
+ NULL, &hKey, NULL) == ERROR_SUCCESS)
+ {
+ if (RegSetValueEx(hKey, _T("Hotkey"), 0, REG_SZ, (LPBYTE)szLang,
+ (DWORD)((1 + 1) * sizeof(TCHAR))) != ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ return;
+ }
+
+ if (RegSetValueEx(hKey, _T("Language Hotkey"), 0, REG_SZ,
(LPBYTE)szLang,
+ (DWORD)((1 + 1) * sizeof(TCHAR))) != ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ return;
+ }
+
+ if (RegSetValueEx(hKey, _T("Layout Hotkey"), 0, REG_SZ,
(LPBYTE)szLayout,
+ (DWORD)((1 + 1) * sizeof(TCHAR))) != ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ return;
+ }
+
+ RegCloseKey(hKey);
+ UpdateKeySettingsList();
+ }
}
static VOID
@@ -174,6 +234,8 @@
break;
case IDOK:
+ SaveKeySeq(hDlg);
+ EndDialog(hDlg, LOWORD(wParam));
break;
case IDCANCEL:
Modified: trunk/reactos/dll/cpl/input/input.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/input.h?rev=…
==============================================================================
--- trunk/reactos/dll/cpl/input/input.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/input.h [iso-8859-1] Sun May 18 04:06:48 2008
@@ -47,6 +47,8 @@
/* keysettings.c */
INT_PTR CALLBACK
KeySettingsDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
+VOID
+UpdateKeySettingsList();
/* add.c */
INT_PTR CALLBACK
Modified: trunk/reactos/dll/cpl/input/keysettings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/keysettings.…
==============================================================================
--- trunk/reactos/dll/cpl/input/keysettings.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/keysettings.c [iso-8859-1] Sun May 18 04:06:48 2008
@@ -11,6 +11,8 @@
#include "resource.h"
#include "input.h"
+
+static HWND hKeySettingsWnd;
static VOID
AddListColumn(HWND hDlg)
@@ -57,6 +59,27 @@
}
static VOID
+SaveKeySettings(HWND hDlg)
+{
+ HKEY hKey;
+ DWORD dwValue;
+
+ if (SendDlgItemMessage(hDlg, IDC_PRESS_CL_KEY_RB, BM_GETCHECK, 0, 0) == BST_CHECKED)
+ dwValue = 0x0;
+ else
+ dwValue = 0x10000;
+
+ if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout"), 0, NULL,
+ REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
+ NULL, &hKey, NULL) == ERROR_SUCCESS)
+ {
+ RegSetValueEx(hKey, _T("Attributes"), 0, REG_DWORD,
(LPBYTE)&dwValue, sizeof(DWORD));
+
+ RegCloseKey(hKey);
+ }
+}
+
+static VOID
InitKeySettingsDlg(HWND hDlg)
{
TCHAR szHotkey[1 + 1], szLangHotkey[1 + 1], szLayoutHotkey[1 + 1],
@@ -78,8 +101,10 @@
if (_tcscmp(szLangHotkey, _T("2")) == 0)
LoadString(hApplet, IDS_CTRL_SHIFT, szText, sizeof(szText) / sizeof(TCHAR));
+ else if (_tcscmp(szLangHotkey, _T("1")) == 0)
+ LoadString(hApplet, IDS_LEFT_ALT_SHIFT, szText, sizeof(szText) / sizeof(TCHAR));
else
- LoadString(hApplet, IDS_LEFT_ALT_SHIFT, szText, sizeof(szText) / sizeof(TCHAR));
+ LoadString(hApplet, IDS_NONE, szText, sizeof(szText) / sizeof(TCHAR));
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
item.pszText = szTitle;
@@ -90,6 +115,13 @@
(VOID) ListView_SetHotItem(hHotkeyList, i);
ListView_SetItemState(hHotkeyList, i, LVIS_SELECTED, LVIS_OVERLAYMASK);
+}
+
+VOID
+UpdateKeySettingsList()
+{
+ (VOID) ListView_DeleteAllItems(GetDlgItem(hKeySettingsWnd, IDC_KEY_LISTVIEW));
+ InitKeySettingsDlg(hKeySettingsWnd);
}
INT_PTR CALLBACK
@@ -103,6 +135,7 @@
switch (message)
{
case WM_INITDIALOG:
+ hKeySettingsWnd = hDlg;
AddListColumn(hDlg);
(VOID) ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_KEY_LISTVIEW),
LVS_EX_FULLROWSELECT);
@@ -120,6 +153,8 @@
break;
case IDOK:
+ SaveKeySettings(hDlg);
+ EndDialog(hDlg, LOWORD(wParam));
break;
case IDCANCEL: