ReactOS 0.4.15-dev-8127-g6338913
key_settings_dialog.c
Go to the documentation of this file.
1/*
2* PROJECT: input.dll
3* FILE: dll/cpl/input/key_settings_dialog.c
4* PURPOSE: input.dll
5* PROGRAMMER: Dmitry Chapyshev (dmitry@reactos.org)
6*/
7
8#include "input.h"
9
11
12
15{
17 HKEY hKey;
18
20 L"Keyboard Layout",
21 0,
24 {
25 DWORD dwSize = sizeof(dwAttributes);
26
28 L"Attributes",
29 NULL, NULL,
31 &dwSize);
32
34 }
35
36 return dwAttributes;
37}
38
39static VOID
41{
42 HKEY hKey;
43
45
47 L"Keyboard Layout\\Toggle",
48 0,
51 {
52 WCHAR szBuffer[MAX_PATH];
54
55 dwSize = sizeof(szBuffer);
56
58 L"Language Hotkey",
59 NULL, NULL,
60 (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS)
61 {
62 _KeySettings.dwLanguage = _wtoi(szBuffer);
63 }
64
65 dwSize = sizeof(szBuffer);
66
68 L"Layout Hotkey",
69 NULL, NULL,
70 (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS)
71 {
72 _KeySettings.dwLayout = _wtoi(szBuffer);
73 }
74
76 }
77}
78
79
80static VOID
82{
83 HKEY hKey;
84
86 L"Keyboard Layout",
87 0,
90 {
92 L"Attributes",
93 0,
96 sizeof(DWORD));
97
99 }
100
102 L"Keyboard Layout\\Toggle",
103 0,
105 &hKey) == ERROR_SUCCESS)
106 {
107 WCHAR szBuffer[MAX_PATH];
108
109 StringCchPrintfW(szBuffer, ARRAYSIZE(szBuffer), L"%lu", _KeySettings.dwLanguage);
110
112 L"Hotkey",
113 0,
114 REG_SZ,
115 (LPBYTE)szBuffer,
116 (wcslen(szBuffer) + 1) * sizeof(WCHAR));
117
119 L"Language Hotkey",
120 0,
121 REG_SZ,
122 (LPBYTE)szBuffer,
123 (wcslen(szBuffer) + 1) * sizeof(WCHAR));
124
125 StringCchPrintfW(szBuffer, ARRAYSIZE(szBuffer), L"%lu", _KeySettings.dwLayout);
126
128 L"Layout Hotkey",
129 0,
130 REG_SZ,
131 (LPBYTE)szBuffer,
132 (wcslen(szBuffer) + 1) * sizeof(WCHAR));
133
135 }
136
137 /* Notice system of change hotkeys parameters */
138 SystemParametersInfoW(SPI_SETLANGTOGGLE, 0, NULL, 0);
139
140 /* Notice system of change CapsLock mode parameters */
142}
143
144
145static VOID
147{
148 WCHAR szBuffer[MAX_STR_LEN];
150 INT iItemIndex;
151
152 ListView_DeleteAllItems(hwndList);
153
154 ZeroMemory(&item, sizeof(item));
155
156 LoadStringW(hApplet, IDS_SWITCH_BET_INLANG, szBuffer, ARRAYSIZE(szBuffer));
158 item.pszText = szBuffer;
159 item.iItem = 0;
160
161 iItemIndex = ListView_InsertItem(hwndList, &item);
162
163 if (_KeySettings.dwLanguage == 1)
164 {
165 LoadStringW(hApplet, IDS_LEFT_ALT_SHIFT, szBuffer, ARRAYSIZE(szBuffer));
166 }
167 else if (_KeySettings.dwLanguage == 2)
168 {
169 LoadStringW(hApplet, IDS_CTRL_SHIFT, szBuffer, ARRAYSIZE(szBuffer));
170 }
171 else
172 {
173 LoadStringW(hApplet, IDS_NONE, szBuffer, ARRAYSIZE(szBuffer));
174 }
175
176 ListView_SetItemText(hwndList, iItemIndex, 1, szBuffer);
177}
178
179
180static VOID
182{
184 HWND hwndList;
185
187
188 if (_KeySettings.dwAttributes & KLF_SHIFTLOCK)
189 {
192 }
193 else
194 {
197 }
198
199 hwndList = GetDlgItem(hwndDlg, IDC_KEY_LISTVIEW);
200
202
203 ZeroMemory(&column, sizeof(column));
204
206
207 column.fmt = LVCFMT_LEFT;
208 column.iSubItem = 0;
209 column.pszText = L"";
210 column.cx = 210;
211 ListView_InsertColumn(hwndList, 0, &column);
212
213 column.fmt = LVCFMT_RIGHT;
214 column.cx = 145;
215 column.iSubItem = 1;
216 column.pszText = L"";
217 ListView_InsertColumn(hwndList, 1, &column);
218
220}
221
222
225{
227
228 switch (uMsg)
229 {
230 case WM_INITDIALOG:
232 return TRUE;
233
234 case WM_COMMAND:
235 {
236 switch (LOWORD(wParam))
237 {
239 {
242 hwndDlg,
245 {
247 }
248 }
249 break;
250
251 case IDOK:
252 {
254 {
255 _KeySettings.dwAttributes &= ~KLF_SHIFTLOCK;
256 }
257 else
258 {
259 _KeySettings.dwAttributes |= KLF_SHIFTLOCK;
260 }
261
263 EndDialog(hwndDlg, LOWORD(wParam));
264 }
265 break;
266
267 case IDCANCEL:
268 {
269 EndDialog(hwndDlg, LOWORD(wParam));
270 }
271 break;
272 }
273 }
274 break;
275 }
276
277 return FALSE;
278}
#define IDS_NONE
Definition: resource.h:133
#define MAX_STR_LEN
Definition: defines.h:43
#define RegCloseKey(hKey)
Definition: registry.h:49
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HINSTANCE hApplet
Definition: access.c:17
INT_PTR CALLBACK ChangeKeySeqDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define IDS_LEFT_ALT_SHIFT
Definition: resource.h:59
#define IDC_CHANGE_KEY_SEQ_BTN
Definition: resource.h:30
#define IDC_PRESS_SHIFT_KEY_RB
Definition: resource.h:28
#define IDS_CTRL_SHIFT
Definition: resource.h:58
#define IDS_SWITCH_BET_INLANG
Definition: resource.h:60
#define IDC_PRESS_CL_KEY_RB
Definition: resource.h:27
#define IDC_KEY_LISTVIEW
Definition: resource.h:29
#define IDD_CHANGE_KEY_SEQ
Definition: resource.h:16
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static VOID OnInitKeySettingsDialog(HWND hwndDlg)
static VOID WriteKeysSettings(VOID)
static KEY_SETTINGS _KeySettings
INT_PTR CALLBACK KeySettingsDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
DWORD ReadAttributes(VOID)
static VOID UpdateKeySettingsListView(HWND hwndList)
static VOID ReadKeysSettings(VOID)
#define REG_SZ
Definition: layer.c:22
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2408
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2636
#define LVIF_STATE
Definition: commctrl.h:2312
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2734
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2725
#define LVIF_PARAM
Definition: commctrl.h:2311
#define LV_ITEM
Definition: commctrl.h:2337
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2414
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2691
#define LVIF_TEXT
Definition: commctrl.h:2309
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define LVCFMT_RIGHT
Definition: commctrl.h:2599
#define LVCF_TEXT
Definition: commctrl.h:2588
#define LV_COLUMN
Definition: commctrl.h:2547
#define REG_DWORD
Definition: sdbapi.c:596
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
DWORD dwAttributes
Definition: input.h:63
DWORD dwLanguage
Definition: input.h:64
DWORD dwLayout
Definition: input.h:65
int32_t INT_PTR
Definition: typedefs.h:64
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
DWORD dwAttributes
Definition: vdmdbg.h:34
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define HKEY_CURRENT_USER
Definition: winreg.h:11
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDCANCEL
Definition: winuser.h:831
#define BST_UNCHECKED
Definition: winuser.h:199
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)
#define BST_CHECKED
Definition: winuser.h:197
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180