Author: tfaber
Date: Sun Jan  6 10:08:10 2013
New Revision: 58122

URL: http://svn.reactos.org/svn/reactos?rev=58122&view=rev
Log:
[EXPLORER_NEW]
- Correctly load and save advanced setting(s). Patch by Edijs Kolesnikovičs.
CORE-6835 #resolve

Added:
    trunk/reactos/base/shell/explorer-new/settings.c   (with props)
Modified:
    trunk/reactos/base/shell/explorer-new/CMakeLists.txt
    trunk/reactos/base/shell/explorer-new/explorer.c
    trunk/reactos/base/shell/explorer-new/precomp.h
    trunk/reactos/base/shell/explorer-new/trayntfy.c
    trunk/reactos/base/shell/explorer-new/trayprop.c

Modified: trunk/reactos/base/shell/explorer-new/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/CMakeLists.txt?rev=58122&r1=58121&r2=58122&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/CMakeLists.txt [iso-8859-1] Sun Jan  
6 10:08:10 2013
@@ -5,6 +5,7 @@
     desktop.c
     dragdrop.c
     explorer.c
+    settings.c
     startmnu.c
     taskband.c
     taskswnd.c

Modified: trunk/reactos/base/shell/explorer-new/explorer.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/explorer.c?rev=58122&r1=58121&r2=58122&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/explorer.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/explorer.c [iso-8859-1] Sun Jan  6 
10:08:10 2013
@@ -370,6 +370,7 @@
 
     hExplorerInstance = hInstance;
     hProcessHeap = GetProcessHeap();
+    LoadAdvancedSettings();
 
     hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
     if (hUser32 != NULL)

Modified: trunk/reactos/base/shell/explorer-new/precomp.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/precomp.h?rev=58122&r1=58121&r2=58122&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/precomp.h [iso-8859-1] Sun Jan  6 
10:08:10 2013
@@ -26,13 +26,6 @@
 #include "initguid.h"
 #include "undoc.h"
 
-/* Structure to hold non-default options*/
-typedef struct _ADVANCED_SETTINGS {
-    BOOL bShowSeconds;
-} ADVANCED_SETTINGS, *PADVANCED_SETTINGS;
-
-extern ADVANCED_SETTINGS AdvancedSettings;
-
 /* dynamic imports due to lack of support in msvc linker libs */
 typedef INT (APIENTRY *REGSHELLHOOK)(HWND, DWORD);
 #ifdef UNICODE
@@ -242,6 +235,26 @@
 TrayMessageLoop(IN OUT ITrayWindow *Tray);
 
 /*
+ * settings.c
+ */
+
+/* Structure to hold non-default options*/
+typedef struct _ADVANCED_SETTINGS {
+    BOOL bShowSeconds;
+} ADVANCED_SETTINGS, *PADVANCED_SETTINGS;
+
+extern ADVANCED_SETTINGS AdvancedSettings;
+extern const TCHAR szAdvancedSettingsKey[];
+
+VOID
+LoadAdvancedSettings(VOID);
+
+BOOL
+SaveSettingDword(IN PCTSTR pszKeyName,
+                 IN PCTSTR pszValueName,
+                 IN DWORD dwValue);
+
+/*
  * trayprop.h
  */
 

Added: trunk/reactos/base/shell/explorer-new/settings.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/settings.c?rev=58122&view=auto
==============================================================================
--- trunk/reactos/base/shell/explorer-new/settings.c (added)
+++ trunk/reactos/base/shell/explorer-new/settings.c [iso-8859-1] Sun Jan  6 
10:08:10 2013
@@ -1,0 +1,66 @@
+/*
+ * ReactOS Explorer
+ *
+ * Copyright 2013 - Edijs Kolesnikovics
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+ */
+
+#include <precomp.h>
+
+ADVANCED_SETTINGS AdvancedSettings;
+const TCHAR szAdvancedSettingsKey[] = 
TEXT("Software\\ReactOS\\Features\\Explorer");
+
+
+VOID
+LoadAdvancedSettings(VOID)
+{
+    HKEY hKey;
+
+    /* Set defaults */
+    AdvancedSettings.bShowSeconds = FALSE;
+
+    /* Check registry */
+    if (RegOpenKey(HKEY_CURRENT_USER, szAdvancedSettingsKey, &hKey) == 
ERROR_SUCCESS)
+    {
+        DWORD dwValue, dwValueLength, dwType;
+
+        dwValueLength = sizeof(dwValue);
+        if (RegQueryValueEx(hKey, TEXT("ShowSeconds"), NULL, &dwType, 
(PBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD)
+            AdvancedSettings.bShowSeconds = dwValue != 0;
+
+        RegCloseKey(hKey);
+    }
+}
+
+BOOL
+SaveSettingDword(IN PCTSTR pszKeyName,
+                 IN PCTSTR pszValueName,
+                 IN DWORD dwValue)
+{
+    BOOL ret = FALSE;
+    HKEY hKey;
+
+    if (RegCreateKey(HKEY_CURRENT_USER, pszKeyName, &hKey) == ERROR_SUCCESS)
+    {
+        ret = RegSetValueEx(hKey, pszValueName, 0, REG_DWORD, (PBYTE)&dwValue, 
sizeof(dwValue)) == ERROR_SUCCESS;
+
+        RegCloseKey(hKey);
+    }
+
+    return ret;
+}
+
+/* EOF */

Propchange: trunk/reactos/base/shell/explorer-new/settings.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/reactos/base/shell/explorer-new/trayntfy.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/trayntfy.c?rev=58122&r1=58121&r2=58122&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/trayntfy.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/trayntfy.c [iso-8859-1] Sun Jan  6 
10:08:10 2013
@@ -701,25 +701,6 @@
     { FALSE, DATE_SHORTDATE, NULL }
 };
 
-HRESULT RegGetDWord(HKEY hKey, LPCTSTR szValueName, DWORD * lpdwResult)
-{
-    LONG lResult;
-    DWORD dwDataSize = sizeof(DWORD);
-    DWORD dwType = 0;
-
-    // Check input parameters...
-    if (hKey == NULL || lpdwResult == NULL) return E_INVALIDARG;
-
-    // Get dword value from the registry...
-    lResult = RegQueryValueEx(hKey, szValueName, 0, &dwType, (LPBYTE) 
lpdwResult, &dwDataSize );
-
-    // Check result and make sure the registry value is a DWORD(REG_DWORD)...
-    if (lResult != ERROR_SUCCESS) return HRESULT_FROM_WIN32(lResult);
-    else if (dwType != REG_DWORD) return DISP_E_TYPEMISMATCH;
-
-    return NOERROR;
-}
-
 #define CLOCKWND_FORMAT_COUNT (sizeof(ClockWndFormats) / 
sizeof(ClockWndFormats[0]))
 
 #define TRAY_CLOCK_WND_SPACING_X    0

Modified: trunk/reactos/base/shell/explorer-new/trayprop.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/trayprop.c?rev=58122&r1=58121&r2=58122&view=diff
==============================================================================
--- trunk/reactos/base/shell/explorer-new/trayprop.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/trayprop.c [iso-8859-1] Sun Jan  6 
10:08:10 2013
@@ -30,8 +30,6 @@
     HBITMAP hTaskbarBitmap;
 } PROPSHEET_INFO, *PPROPSHEET_INFO;
 
-ADVANCED_SETTINGS AdvancedSettings = { FALSE };
-
 
 static BOOL
 UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
@@ -225,6 +223,7 @@
 
                 case PSN_APPLY:
                     AdvancedSettings.bShowSeconds = 
IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SECONDS);
+                    SaveSettingDword(szAdvancedSettingsKey, 
TEXT("ShowSeconds"), AdvancedSettings.bShowSeconds);
                     break;
             }
 


Reply via email to