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