1 /* 2 * PROJECT: ReactOS Magnify 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/applications/magnify/settings.c 5 * PURPOSE: Magnification of parts of the screen. 6 * COPYRIGHT: Copyright 2007 Marc Piulachs <marc.piulachs@codexchange.net> 7 * 8 */ 9 10 #include "magnifier.h" 11 12 #include <tchar.h> 13 #include <winreg.h> 14 15 int iZoom = 3; 16 17 BOOL bShowWarning = TRUE; 18 19 BOOL bFollowMouse = TRUE; 20 BOOL bFollowFocus = TRUE; 21 BOOL bFollowCaret = TRUE; 22 23 BOOL bInvertColors = FALSE; 24 BOOL bStartMinimized = FALSE; 25 BOOL bShowMagnifier = TRUE; 26 27 struct _AppBarConfig_t AppBarConfig = { 28 sizeof(struct _AppBarConfig_t), 29 -2 /* ABE_TOP */, 30 0, 1, /* unknown */ 31 { 101,101,101,101 }, /* edge sizes */ 32 { 20, 20, 600, 200 }, /* floating window rect */ 33 }; 34 35 void LoadSettings() 36 { 37 HKEY hkey; 38 LONG value; 39 ULONG len; 40 struct _AppBarConfig_t config_temp; 41 42 if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, KEY_READ, &hkey) == ERROR_SUCCESS) 43 { 44 len = sizeof(AppBarConfig); 45 if (RegQueryValueEx(hkey, _T("AppBar"), 0, 0, (BYTE *)&config_temp, &len) == ERROR_SUCCESS) 46 { 47 if(config_temp.cbSize == sizeof(AppBarConfig)) 48 { 49 AppBarConfig = config_temp; 50 } 51 } 52 53 len = 4; 54 if (RegQueryValueEx(hkey, _T("StationaryMagLevel"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS) 55 { 56 if (value >= 0 && value <= 9) 57 iZoom = value; 58 } 59 60 len = 4; 61 if (RegQueryValueEx(hkey, _T("ShowWarning"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS) 62 bShowWarning = (value == 0 ? FALSE : TRUE); 63 64 len = 4; 65 if (RegQueryValueEx(hkey, _T("StationaryInvertColors"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS) 66 bInvertColors = (value == 0 ? FALSE : TRUE); 67 68 len = 4; 69 if (RegQueryValueEx(hkey, _T("StationaryStartMinimized"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS) 70 bStartMinimized = (value == 0 ? FALSE : TRUE); 71 72 len = 4; 73 if (RegQueryValueEx(hkey, _T("StationaryTrackCursor"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS) 74 bFollowMouse = (value == 0 ? FALSE : TRUE); 75 76 len = 4; 77 if (RegQueryValueEx(hkey, _T("StationaryTrackFocus"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS) 78 bFollowFocus = (value == 0 ? FALSE : TRUE); 79 80 len = 4; 81 if (RegQueryValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS) 82 bFollowFocus = (value == 0 ? FALSE : TRUE); 83 84 len = 4; 85 if (RegQueryValueEx(hkey, _T("StationaryTrackText"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS) 86 bFollowCaret = (value == 0 ? FALSE : TRUE); 87 88 RegCloseKey(hkey); 89 } 90 } 91 92 void SaveSettings() 93 { 94 HKEY hkey; 95 LONG value; 96 97 if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, _T(""), 0, KEY_WRITE, NULL, &hkey, NULL) == ERROR_SUCCESS) 98 { 99 RegSetValueEx(hkey, _T("AppBar"), 0, REG_BINARY, (BYTE *)&AppBarConfig, sizeof(AppBarConfig)); 100 101 value = iZoom; 102 RegSetValueEx(hkey, _T("StationaryMagLevel"), 0, REG_DWORD, (BYTE *)&value, sizeof(value)); 103 104 value = bShowWarning; 105 RegSetValueEx(hkey, _T("ShowWarning"), 0, REG_DWORD, (BYTE *)&value, sizeof(value)); 106 107 value = bInvertColors; 108 RegSetValueEx(hkey, _T("StationaryInvertColors"), 0, REG_DWORD, (BYTE *)&value, sizeof(value)); 109 110 value = bStartMinimized; 111 RegSetValueEx(hkey, _T("StationaryStartMinimized"), 0, REG_DWORD, (BYTE *)&value, sizeof(value)); 112 113 value = bFollowMouse; 114 RegSetValueEx(hkey, _T("StationaryTrackCursor"), 0, REG_DWORD, (BYTE *)&value, sizeof(value)); 115 116 value = bFollowFocus; 117 RegSetValueEx(hkey, _T("StationaryTrackFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof(value)); 118 119 value = bFollowFocus; 120 RegSetValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof(value)); 121 122 value = bFollowCaret; 123 RegSetValueEx(hkey, _T("StationaryTrackText"), 0, REG_DWORD, (BYTE *)&value, sizeof(value)); 124 125 RegCloseKey(hkey); 126 } 127 } 128