[EXPLORER_NEW]

- Correctly load and save advanced setting(s). Patch by Edijs Kolesnikovičs.
CORE-6835 #resolve

svn path=/trunk/; revision=58122
This commit is contained in:
Thomas Faber 2013-01-06 10:08:10 +00:00
parent 638a8ff859
commit b9a482f6fd
6 changed files with 89 additions and 28 deletions

View file

@ -5,6 +5,7 @@ list(APPEND SOURCE
desktop.c
dragdrop.c
explorer.c
settings.c
startmnu.c
taskband.c
taskswnd.c

View file

@ -370,6 +370,7 @@ _tWinMain(IN HINSTANCE hInstance,
hExplorerInstance = hInstance;
hProcessHeap = GetProcessHeap();
LoadAdvancedSettings();
hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
if (hUser32 != NULL)

View file

@ -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
@ -241,6 +234,26 @@ TrayProcessMessages(IN OUT ITrayWindow *Tray);
VOID
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
*/

View file

@ -0,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 */

View file

@ -701,25 +701,6 @@ static const struct
{ 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

View file

@ -30,8 +30,6 @@ typedef struct _PROPSHEET_INFO
HBITMAP hTaskbarBitmap;
} PROPSHEET_INFO, *PPROPSHEET_INFO;
ADVANCED_SETTINGS AdvancedSettings = { FALSE };
static BOOL
UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
@ -225,6 +223,7 @@ AdvancedSettingsPageProc(HWND hwndDlg,
case PSN_APPLY:
AdvancedSettings.bShowSeconds = IsDlgButtonChecked(hwndDlg, IDC_TASKBARPROP_SECONDS);
SaveSettingDword(szAdvancedSettingsKey, TEXT("ShowSeconds"), AdvancedSettings.bShowSeconds);
break;
}