Author: bfreisen
Date: Mon Aug 8 14:00:18 2016
New Revision: 72158
URL:
http://svn.reactos.org/svn/reactos?rev=72158&view=rev
Log:
[MSPAINT] Handle settings from registry correctly. Patch by Carlo Bramini. CORE-11400
Modified:
trunk/reactos/base/applications/mspaint/registry.cpp
Modified: trunk/reactos/base/applications/mspaint/registry.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint/…
==============================================================================
--- trunk/reactos/base/applications/mspaint/registry.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint/registry.cpp [iso-8859-1] Mon Aug 8 14:00:18
2016
@@ -13,6 +13,19 @@
#include <winreg.h>
/* FUNCTIONS ********************************************************/
+static DWORD ReadDWORD(HKEY hKey, LPCTSTR lpName, DWORD *pdwValue, BOOL bCheckForDef)
+{
+ DWORD dwPrev = *pdwValue;
+ DWORD cbData = sizeof(DWORD);
+
+ if (ERROR_SUCCESS != RegQueryValueEx(hKey, lpName, 0, NULL, (LPBYTE) pdwValue,
&cbData))
+ *pdwValue = dwPrev;
+
+ if (bCheckForDef && *pdwValue == 0)
+ *pdwValue = dwPrev;
+
+ return dwPrev;
+}
void RegistrySettings::SetWallpaper(TCHAR * FileName, DWORD dwStyle, DWORD dwTile)
//FIXME: Has to be called 2x to apply the pattern (tiled/stretched) too
{
@@ -75,28 +88,19 @@
0, KEY_READ | KEY_SET_VALUE, &hView) == ERROR_SUCCESS)
{
DWORD cbData;
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("BMPHeight"), 0, NULL, (LPBYTE)
&BMPHeight, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("BMPWidth"), 0, NULL, (LPBYTE) &BMPWidth,
&cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("GridExtent"), 0, NULL, (LPBYTE)
&GridExtent, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("NoStretching"), 0, NULL, (LPBYTE)
&NoStretching, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("ShowThumbnail"), 0, NULL, (LPBYTE)
&ShowThumbnail, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("SnapToGrid"), 0, NULL, (LPBYTE)
&SnapToGrid, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("ThumbHeight"), 0, NULL, (LPBYTE)
&ThumbHeight, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("ThumbWidth"), 0, NULL, (LPBYTE)
&ThumbWidth, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("ThumbXPos"), 0, NULL, (LPBYTE)
&ThumbXPos, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("ThumbYPos"), 0, NULL, (LPBYTE)
&ThumbYPos, &cbData);
- cbData = sizeof(DWORD);
- RegQueryValueEx(hView, _T("UnitSetting"), 0, NULL, (LPBYTE)
&UnitSetting, &cbData);
+
+ ReadDWORD(hView, _T("BMPHeight"), &BMPHeight, TRUE);
+ ReadDWORD(hView, _T("BMPWidth"), &BMPWidth, TRUE);
+ ReadDWORD(hView, _T("GridExtent"), &GridExtent, FALSE);
+ ReadDWORD(hView, _T("NoStretching"), &NoStretching, FALSE);
+ ReadDWORD(hView, _T("ShowThumbnail"), &ShowThumbnail, FALSE);
+ ReadDWORD(hView, _T("SnapToGrid"), &SnapToGrid, FALSE);
+ ReadDWORD(hView, _T("ThumbHeight"), &ThumbHeight, TRUE);
+ ReadDWORD(hView, _T("ThumbWidth"), &ThumbWidth, TRUE);
+ ReadDWORD(hView, _T("ThumbXPos"), &ThumbXPos, TRUE);
+ ReadDWORD(hView, _T("ThumbYPos"), &ThumbYPos, TRUE);
+ ReadDWORD(hView, _T("UnitSetting"), &UnitSetting, FALSE);
+
cbData = sizeof(WINDOWPLACEMENT);
RegQueryValueEx(hView, _T("WindowPlacement"), 0, NULL, (LPBYTE)
&WindowPlacement, &cbData);
}