ReactOS  0.4.14-dev-77-gd9e7c48
key_settings_dialog.c File Reference
#include "input.h"
Include dependency graph for key_settings_dialog.c:

Go to the source code of this file.

Functions

DWORD ReadAttributes (VOID)
 
static VOID ReadKeysSettings (VOID)
 
static VOID WriteKeysSettings (VOID)
 
static VOID UpdateKeySettingsListView (HWND hwndList)
 
static VOID OnInitKeySettingsDialog (HWND hwndDlg)
 
INT_PTR CALLBACK KeySettingsDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static KEY_SETTINGS _KeySettings = { 0 }
 

Function Documentation

◆ KeySettingsDialogProc()

INT_PTR CALLBACK KeySettingsDialogProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 224 of file key_settings_dialog.c.

225 {
227 
228  switch (uMsg)
229  {
230  case WM_INITDIALOG:
231  {
232  OnInitKeySettingsDialog(hwndDlg);
233  }
234  break;
235 
236  case WM_COMMAND:
237  {
238  switch (LOWORD(wParam))
239  {
241  {
244  hwndDlg,
246  (LPARAM)&_KeySettings) == IDOK)
247  {
249  }
250  }
251  break;
252 
253  case IDOK:
254  {
256  {
257  _KeySettings.dwAttributes &= ~KLF_SHIFTLOCK;
258  }
259  else
260  {
261  _KeySettings.dwAttributes |= KLF_SHIFTLOCK;
262  }
263 
265  EndDialog(hwndDlg, LOWORD(wParam));
266  }
267  break;
268 
269  case IDCANCEL:
270  {
271  EndDialog(hwndDlg, LOWORD(wParam));
272  }
273  break;
274  }
275  }
276  break;
277  }
278 
279  return FALSE;
280 }
#define IDOK
Definition: winuser.h:824
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
static VOID UpdateKeySettingsListView(HWND hwndList)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IDC_CHANGE_KEY_SEQ_BTN
Definition: resource.h:29
HINSTANCE hApplet
Definition: access.c:17
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define IDD_CHANGE_KEY_SEQ
Definition: resource.h:15
#define IDC_KEY_LISTVIEW
Definition: resource.h:28
#define IDC_PRESS_CL_KEY_RB
Definition: resource.h:26
LONG_PTR LPARAM
Definition: windef.h:208
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
INT_PTR CALLBACK ChangeKeySeqDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
static VOID OnInitKeySettingsDialog(HWND hwndDlg)
#define BST_CHECKED
Definition: winuser.h:197
DWORD dwAttributes
Definition: input.h:61
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static KEY_SETTINGS _KeySettings
static VOID WriteKeysSettings(VOID)

Referenced by OnCommandSettingsPage().

◆ OnInitKeySettingsDialog()

static VOID OnInitKeySettingsDialog ( HWND  hwndDlg)
static

Definition at line 181 of file key_settings_dialog.c.

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 
219  UpdateKeySettingsListView(hwndList);
220 }
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define LVCF_WIDTH
Definition: commctrl.h:2559
static VOID UpdateKeySettingsListView(HWND hwndList)
#define LVCF_TEXT
Definition: commctrl.h:2560
#define LV_COLUMN
Definition: commctrl.h:2519
#define IDC_PRESS_SHIFT_KEY_RB
Definition: resource.h:27
#define LVCFMT_RIGHT
Definition: commctrl.h:2571
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2706
#define LVCFMT_LEFT
Definition: commctrl.h:2570
#define ZeroMemory
Definition: winbase.h:1635
#define LVCF_SUBITEM
Definition: commctrl.h:2561
#define IDC_KEY_LISTVIEW
Definition: resource.h:28
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2608
#define IDC_PRESS_CL_KEY_RB
Definition: resource.h:26
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2697
static VOID ReadKeysSettings(VOID)
static const WCHAR L[]
Definition: oid.c:1250
#define BST_UNCHECKED
Definition: winuser.h:199
#define LVCF_FMT
Definition: commctrl.h:2558
#define BST_CHECKED
Definition: winuser.h:197
DWORD dwAttributes
Definition: input.h:61
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
static KEY_SETTINGS _KeySettings

Referenced by KeySettingsDialogProc().

◆ ReadAttributes()

DWORD ReadAttributes ( VOID  )

Definition at line 14 of file key_settings_dialog.c.

15 {
16  DWORD dwAttributes = 0;
17  HKEY hKey;
18 
20  L"Keyboard Layout",
21  0,
23  &hKey) == ERROR_SUCCESS)
24  {
25  DWORD dwSize = sizeof(dwAttributes);
26 
27  RegQueryValueExW(hKey,
28  L"Attributes",
29  NULL, NULL,
31  &dwSize);
32 
33  RegCloseKey(hKey);
34  }
35 
36  return dwAttributes;
37 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
DWORD dwAttributes
Definition: vdmdbg.h:34
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by ReadKeysSettings().

◆ ReadKeysSettings()

static VOID ReadKeysSettings ( VOID  )
static

Definition at line 40 of file key_settings_dialog.c.

41 {
42  HKEY hKey;
43 
45 
47  L"Keyboard Layout\\Toggle",
48  0,
50  &hKey) == ERROR_SUCCESS)
51  {
52  WCHAR szBuffer[MAX_PATH];
53  DWORD dwSize;
54 
55  dwSize = sizeof(szBuffer);
56 
57  if (RegQueryValueExW(hKey,
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 
67  if (RegQueryValueExW(hKey,
68  L"Layout Hotkey",
69  NULL, NULL,
70  (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS)
71  {
72  _KeySettings.dwLayout = _wtoi(szBuffer);
73  }
74 
75  RegCloseKey(hKey);
76  }
77 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
DWORD dwLayout
Definition: input.h:63
DWORD dwLanguage
Definition: input.h:62
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD ReadAttributes(VOID)
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
DWORD dwAttributes
Definition: input.h:61
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
static KEY_SETTINGS _KeySettings

Referenced by OnInitKeySettingsDialog().

◆ UpdateKeySettingsListView()

static VOID UpdateKeySettingsListView ( HWND  hwndList)
static

Definition at line 146 of file key_settings_dialog.c.

147 {
148  WCHAR szBuffer[MAX_STR_LEN];
149  LV_ITEM item;
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));
157  item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
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 }
#define LV_ITEM
Definition: commctrl.h:2309
#define IDS_NONE
Definition: resource.h:122
DWORD dwLanguage
Definition: input.h:62
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hApplet
Definition: access.c:17
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define LVIF_TEXT
Definition: commctrl.h:2281
#define IDS_SWITCH_BET_INLANG
Definition: resource.h:58
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2663
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDS_LEFT_ALT_SHIFT
Definition: resource.h:57
static ATOM item
Definition: dde.c:856
#define MAX_STR_LEN
Definition: defines.h:33
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVIF_STATE
Definition: commctrl.h:2284
static KEY_SETTINGS _KeySettings
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2386
#define IDS_CTRL_SHIFT
Definition: resource.h:56

Referenced by KeySettingsDialogProc(), and OnInitKeySettingsDialog().

◆ WriteKeysSettings()

static VOID WriteKeysSettings ( VOID  )
static

Definition at line 81 of file key_settings_dialog.c.

82 {
83  HKEY hKey;
84 
86  L"Keyboard Layout",
87  0,
89  &hKey) == ERROR_SUCCESS)
90  {
91  RegSetValueExW(hKey,
92  L"Attributes",
93  0,
94  REG_DWORD,
96  sizeof(DWORD));
97 
98  RegCloseKey(hKey);
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 
111  RegSetValueExW(hKey,
112  L"Hotkey",
113  0,
114  REG_SZ,
115  (LPBYTE)szBuffer,
116  (wcslen(szBuffer) + 1) * sizeof(WCHAR));
117 
118  RegSetValueExW(hKey,
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 
127  RegSetValueExW(hKey,
128  L"Layout Hotkey",
129  0,
130  REG_SZ,
131  (LPBYTE)szBuffer,
132  (wcslen(szBuffer) + 1) * sizeof(WCHAR));
133 
134  RegCloseKey(hKey);
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 }
HKL WINAPI ActivateKeyboardLayout(_In_ HKL, _In_ UINT)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define HKEY_CURRENT_USER
Definition: winreg.h:11
DWORD dwLayout
Definition: input.h:63
DWORD dwLanguage
Definition: input.h:62
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
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:4895
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
DWORD dwAttributes
Definition: input.h:61
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define REG_DWORD
Definition: sdbapi.c:596
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static KEY_SETTINGS _KeySettings
#define REG_SZ
Definition: layer.c:22

Referenced by KeySettingsDialogProc().

Variable Documentation

◆ _KeySettings