sync with trunk r46493
[reactos.git] / base / applications / magnify / settings.c
1 #include <windows.h>
2 #include <tchar.h>
3 #include "magnifier.h"
4
5 int iZoom = 3;
6
7 BOOL bShowWarning = TRUE;
8
9 BOOL bFollowMouse = TRUE;
10 BOOL bFollowFocus = TRUE;
11 BOOL bFollowCaret = TRUE;
12
13 BOOL bInvertColors = FALSE;
14 BOOL bStartMinimized = FALSE;
15 BOOL bShowMagnifier = TRUE;
16
17 void LoadSettings()
18 {
19 HKEY hkey;
20 LONG value;
21 ULONG len;
22
23 RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0,
24 _T(""), 0, KEY_READ, NULL, &hkey, NULL);
25
26 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryMagLevel"), 0, 0, (BYTE *)&value, &len))
27 {
28 if(value >= 0 && value <= 9)
29 iZoom = value;
30 }
31
32 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("ShowWarning"), 0, 0, (BYTE *)&value, &len))
33 bShowWarning = (value == 0 ? FALSE : TRUE);
34
35 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryInvertColors"), 0, 0, (BYTE *)&value, &len))
36 bInvertColors = (value == 0 ? FALSE : TRUE);
37
38 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryStartMinimized"), 0, 0, (BYTE *)&value, &len))
39 bStartMinimized = (value == 0 ? FALSE : TRUE);
40
41 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackCursor"), 0, 0, (BYTE *)&value, &len))
42 bFollowMouse = (value == 0 ? FALSE : TRUE);
43
44 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackFocus"), 0, 0, (BYTE *)&value, &len))
45 bFollowFocus = (value == 0 ? FALSE : TRUE);
46
47 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, 0, (BYTE *)&value, &len))
48 bFollowFocus = (value == 0 ? FALSE : TRUE);
49
50 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackText"), 0, 0, (BYTE *)&value, &len))
51 bFollowCaret = (value == 0 ? FALSE : TRUE);
52
53 RegCloseKey(hkey);
54 }
55
56 void SaveSettings()
57 {
58 HKEY hkey;
59 LONG value;
60
61 RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0,
62 _T(""), 0, KEY_WRITE, NULL, &hkey, NULL);
63
64 value = iZoom;
65 RegSetValueEx(hkey, _T("StationaryMagLevel"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
66
67 value = bShowWarning;
68 RegSetValueEx(hkey, _T("ShowWarning"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
69
70 value = bInvertColors;
71 RegSetValueEx(hkey, _T("StationaryInvertColors"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
72
73 value = bStartMinimized;
74 RegSetValueEx(hkey, _T("StationaryStartMinimized"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
75
76 value = bFollowMouse;
77 RegSetValueEx(hkey, _T("StationaryTrackCursor"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
78
79 value = bFollowFocus;
80 RegSetValueEx(hkey, _T("StationaryTrackFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
81
82 value = bFollowFocus;
83 RegSetValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
84
85 value = bFollowCaret;
86 RegSetValueEx(hkey, _T("StationaryTrackText"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
87
88 RegCloseKey(hkey);
89 }