1 /*
2 * PROJECT: input.dll
3 * FILE: dll/cpl/input/key_sequence_dialog.c
4 * PURPOSE: input.dll
5 * PROGRAMMER: Dmitry Chapyshev (dmitry@reactos.org)
6 */
7
8 #include "input.h"
9
10
11 INT_PTR CALLBACK
ChangeKeySeqDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)12 ChangeKeySeqDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
13 {
14 UNREFERENCED_PARAMETER(lParam);
15
16 switch (uMsg)
17 {
18 case WM_INITDIALOG:
19 {
20 KEY_SETTINGS *keySettings = (KEY_SETTINGS*) lParam;
21
22 if (keySettings != NULL)
23 {
24 SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR) keySettings);
25
26 if (keySettings->dwLanguage == 3)
27 {
28 CheckDlgButton(hwndDlg, IDC_CTRL_LANG, BST_CHECKED);
29 EnableWindow(GetDlgItem(hwndDlg, IDC_CTRL_LANG), FALSE);
30 EnableWindow(GetDlgItem(hwndDlg, IDC_LEFT_ALT_LANG), FALSE);
31 }
32 else
33 {
34 CheckDlgButton(hwndDlg, IDC_SWITCH_INPUT_LANG_CB, BST_CHECKED);
35
36 if (keySettings->dwLanguage == 1)
37 {
38 CheckDlgButton(hwndDlg, IDC_LEFT_ALT_LANG, BST_CHECKED);
39 }
40 else
41 {
42 CheckDlgButton(hwndDlg, IDC_CTRL_LANG, BST_CHECKED);
43 }
44 }
45
46 if (keySettings->dwLayout == 3)
47 {
48 CheckDlgButton(hwndDlg, IDC_LEFT_ALT_LAYOUT, BST_CHECKED);
49 EnableWindow(GetDlgItem(hwndDlg, IDC_CTRL_LAYOUT), FALSE);
50 EnableWindow(GetDlgItem(hwndDlg, IDC_LEFT_ALT_LAYOUT), FALSE);
51 }
52 else
53 {
54 CheckDlgButton(hwndDlg, IDC_SWITCH_KBLAYOUTS_CB, BST_CHECKED);
55
56 if (keySettings->dwLayout == 1)
57 {
58 CheckDlgButton(hwndDlg, IDC_LEFT_ALT_LAYOUT, BST_CHECKED);
59 }
60 else
61 {
62 CheckDlgButton(hwndDlg, IDC_CTRL_LAYOUT, BST_CHECKED);
63 }
64 }
65 }
66 return TRUE;
67 }
68
69 case WM_COMMAND:
70 {
71 switch (LOWORD(wParam))
72 {
73 case IDC_SWITCH_INPUT_LANG_CB:
74 {
75 if (HIWORD(wParam) == BN_CLICKED)
76 {
77 if (IsDlgButtonChecked(hwndDlg, IDC_SWITCH_INPUT_LANG_CB) == BST_CHECKED)
78 {
79 EnableWindow(GetDlgItem(hwndDlg, IDC_CTRL_LANG), TRUE);
80 EnableWindow(GetDlgItem(hwndDlg, IDC_LEFT_ALT_LANG), TRUE);
81 }
82 else
83 {
84 EnableWindow(GetDlgItem(hwndDlg, IDC_CTRL_LANG), FALSE);
85 EnableWindow(GetDlgItem(hwndDlg, IDC_LEFT_ALT_LANG), FALSE);
86 }
87 }
88 }
89 break;
90
91 case IDC_SWITCH_KBLAYOUTS_CB:
92 {
93 if (HIWORD(wParam) == BN_CLICKED)
94 {
95 if (IsDlgButtonChecked(hwndDlg, IDC_SWITCH_KBLAYOUTS_CB) == BST_CHECKED)
96 {
97 EnableWindow(GetDlgItem(hwndDlg, IDC_CTRL_LAYOUT), TRUE);
98 EnableWindow(GetDlgItem(hwndDlg, IDC_LEFT_ALT_LAYOUT), TRUE);
99 }
100 else
101 {
102 EnableWindow(GetDlgItem(hwndDlg, IDC_CTRL_LAYOUT), FALSE);
103 EnableWindow(GetDlgItem(hwndDlg, IDC_LEFT_ALT_LAYOUT), FALSE);
104 }
105 }
106 }
107 break;
108
109 case IDC_CTRL_LANG:
110 {
111 if (HIWORD(wParam) == BN_CLICKED)
112 {
113 CheckDlgButton(hwndDlg, IDC_LEFT_ALT_LAYOUT, BST_CHECKED);
114 CheckDlgButton(hwndDlg, IDC_CTRL_LAYOUT, BST_UNCHECKED);
115 }
116 }
117 break;
118
119 case IDC_LEFT_ALT_LANG:
120 {
121 if (HIWORD(wParam) == BN_CLICKED)
122 {
123 CheckDlgButton(hwndDlg, IDC_CTRL_LAYOUT, BST_CHECKED);
124 CheckDlgButton(hwndDlg, IDC_LEFT_ALT_LAYOUT, BST_UNCHECKED);
125 }
126 }
127 break;
128
129 case IDC_CTRL_LAYOUT:
130 {
131 if (HIWORD(wParam) == BN_CLICKED)
132 {
133 CheckDlgButton(hwndDlg, IDC_LEFT_ALT_LANG, BST_CHECKED);
134 CheckDlgButton(hwndDlg, IDC_CTRL_LANG, BST_UNCHECKED);
135 }
136 }
137 break;
138
139 case IDC_LEFT_ALT_LAYOUT:
140 {
141 if (HIWORD(wParam) == BN_CLICKED)
142 {
143 CheckDlgButton(hwndDlg, IDC_CTRL_LANG, BST_CHECKED);
144 CheckDlgButton(hwndDlg, IDC_LEFT_ALT_LANG, BST_UNCHECKED);
145 }
146 }
147 break;
148
149 case IDOK:
150 {
151 KEY_SETTINGS *keySettings;
152
153 keySettings = (KEY_SETTINGS*)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
154
155 if (keySettings != NULL)
156 {
157 if (IsDlgButtonChecked(hwndDlg, IDC_SWITCH_INPUT_LANG_CB) == BST_CHECKED)
158 {
159 if (IsDlgButtonChecked(hwndDlg, IDC_CTRL_LANG) == BST_CHECKED)
160 {
161 keySettings->dwLanguage = 2;
162 }
163 else
164 {
165 keySettings->dwLanguage = 1;
166 }
167 }
168 else
169 {
170 keySettings->dwLanguage = 3;
171 }
172
173 if (IsDlgButtonChecked(hwndDlg, IDC_SWITCH_KBLAYOUTS_CB) == BST_CHECKED)
174 {
175 if (IsDlgButtonChecked(hwndDlg, IDC_CTRL_LAYOUT) == BST_CHECKED)
176 {
177 keySettings->dwLayout = 2;
178 }
179 else
180 {
181 keySettings->dwLayout = 1;
182 }
183 }
184 else
185 {
186 keySettings->dwLayout = 3;
187 }
188 }
189
190 EndDialog(hwndDlg, LOWORD(wParam));
191 }
192 break;
193
194 case IDCANCEL:
195 {
196 EndDialog(hwndDlg, LOWORD(wParam));
197 }
198 break;
199 }
200 }
201 break;
202 }
203
204 return FALSE;
205 }
206