[MSPAINT] Handle settings from registry correctly. Patch by Carlo Bramini. CORE-11400

svn path=/trunk/; revision=72158
This commit is contained in:
Benedikt Freisen 2016-08-08 14:00:18 +00:00
parent 77624f187f
commit 3185db7675

View file

@ -13,6 +13,19 @@
#include <winreg.h> #include <winreg.h>
/* FUNCTIONS ********************************************************/ /* 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 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 @@ void RegistrySettings::Load()
0, KEY_READ | KEY_SET_VALUE, &hView) == ERROR_SUCCESS) 0, KEY_READ | KEY_SET_VALUE, &hView) == ERROR_SUCCESS)
{ {
DWORD cbData; DWORD cbData;
cbData = sizeof(DWORD);
RegQueryValueEx(hView, _T("BMPHeight"), 0, NULL, (LPBYTE) &BMPHeight, &cbData); ReadDWORD(hView, _T("BMPHeight"), &BMPHeight, TRUE);
cbData = sizeof(DWORD); ReadDWORD(hView, _T("BMPWidth"), &BMPWidth, TRUE);
RegQueryValueEx(hView, _T("BMPWidth"), 0, NULL, (LPBYTE) &BMPWidth, &cbData); ReadDWORD(hView, _T("GridExtent"), &GridExtent, FALSE);
cbData = sizeof(DWORD); ReadDWORD(hView, _T("NoStretching"), &NoStretching, FALSE);
RegQueryValueEx(hView, _T("GridExtent"), 0, NULL, (LPBYTE) &GridExtent, &cbData); ReadDWORD(hView, _T("ShowThumbnail"), &ShowThumbnail, FALSE);
cbData = sizeof(DWORD); ReadDWORD(hView, _T("SnapToGrid"), &SnapToGrid, FALSE);
RegQueryValueEx(hView, _T("NoStretching"), 0, NULL, (LPBYTE) &NoStretching, &cbData); ReadDWORD(hView, _T("ThumbHeight"), &ThumbHeight, TRUE);
cbData = sizeof(DWORD); ReadDWORD(hView, _T("ThumbWidth"), &ThumbWidth, TRUE);
RegQueryValueEx(hView, _T("ShowThumbnail"), 0, NULL, (LPBYTE) &ShowThumbnail, &cbData); ReadDWORD(hView, _T("ThumbXPos"), &ThumbXPos, TRUE);
cbData = sizeof(DWORD); ReadDWORD(hView, _T("ThumbYPos"), &ThumbYPos, TRUE);
RegQueryValueEx(hView, _T("SnapToGrid"), 0, NULL, (LPBYTE) &SnapToGrid, &cbData); ReadDWORD(hView, _T("UnitSetting"), &UnitSetting, FALSE);
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);
cbData = sizeof(WINDOWPLACEMENT); cbData = sizeof(WINDOWPLACEMENT);
RegQueryValueEx(hView, _T("WindowPlacement"), 0, NULL, (LPBYTE) &WindowPlacement, &cbData); RegQueryValueEx(hView, _T("WindowPlacement"), 0, NULL, (LPBYTE) &WindowPlacement, &cbData);
} }