1 /*
2 * PROJECT: input.dll
3 * FILE: dll/cpl/input/advanced_settings_page.c
4 * PURPOSE: input.dll
5 * PROGRAMMER: Dmitry Chapyshev (dmitry@reactos.org)
6 * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
7 */
8
9 #include "input.h"
10
11 BOOL g_bTextServiceIsOff = FALSE;
12
LoadAdvancedSettings(HWND hwndDlg)13 BOOL LoadAdvancedSettings(HWND hwndDlg)
14 {
15 HKEY hKey;
16 LRESULT error;
17 DWORD dwType;
18 DWORD dwValue;
19 DWORD cbValue = sizeof(dwValue);
20
21 error = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\CTF", 0, KEY_READ, &hKey);
22 if (error != ERROR_SUCCESS)
23 return FALSE;
24
25 error = RegQueryValueExW(hKey,
26 L"Disable Thread Input Manager",
27 NULL,
28 &dwType,
29 (LPBYTE)&dwValue,
30 &cbValue);
31 if ((error != ERROR_SUCCESS) || (dwType != REG_DWORD) || (cbValue != sizeof(dwValue)))
32 dwValue = FALSE; /* Default */
33
34 RegCloseKey(hKey);
35
36 CheckDlgButton(hwndDlg, IDC_TURNOFFTEXTSVCS_CB, (dwValue ? BST_CHECKED : BST_UNCHECKED));
37 g_bTextServiceIsOff = !!dwValue;
38 return TRUE;
39 }
40
SaveAdvancedSettings(HWND hwndDlg)41 BOOL SaveAdvancedSettings(HWND hwndDlg)
42 {
43 HKEY hKey;
44 LRESULT error;
45 const DWORD dwValue = g_bTextServiceIsOff;
46 const DWORD cbValue = sizeof(dwValue);
47
48 error = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\CTF", 0, KEY_WRITE, &hKey);
49 if (error != ERROR_SUCCESS)
50 return FALSE;
51
52 error = RegSetValueExW(hKey, L"Disable Thread Input Manager", 0, REG_DWORD,
53 (const BYTE *)&dwValue, cbValue);
54
55 RegCloseKey(hKey);
56 return (error == ERROR_SUCCESS);
57 }
58
OnNotifyAdvancedSettingsPage(HWND hwndDlg,LPARAM lParam)59 static INT_PTR OnNotifyAdvancedSettingsPage(HWND hwndDlg, LPARAM lParam)
60 {
61 LPNMHDR header = (LPNMHDR)lParam;
62
63 switch (header->code)
64 {
65 case PSN_APPLY:
66 {
67 BOOL bOff = (IsDlgButtonChecked(hwndDlg, IDC_TURNOFFTEXTSVCS_CB) == BST_CHECKED);
68 g_bRebootNeeded |= (g_bTextServiceIsOff && !bOff);
69 g_bTextServiceIsOff = bOff;
70
71 /* Write advanced settings */
72 SaveAdvancedSettings(hwndDlg);
73 break;
74 }
75 }
76
77 return 0;
78 }
79
80 INT_PTR CALLBACK
AdvancedSettingsPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)81 AdvancedSettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
82 {
83 switch (uMsg)
84 {
85 case WM_INITDIALOG:
86 LoadAdvancedSettings(hwndDlg);
87 return TRUE;
88
89 case WM_NOTIFY:
90 return OnNotifyAdvancedSettingsPage(hwndDlg, lParam);
91
92 case WM_COMMAND:
93 {
94 switch (LOWORD(wParam))
95 {
96 case IDC_TURNOFFTEXTSVCS_CB:
97 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
98 break;
99 }
100 break;
101 }
102 }
103
104 return 0;
105 }
106