Author: bfreisen
Date: Sun Aug 16 19:52:37 2015
New Revision: 68724
URL:
http://svn.reactos.org/svn/reactos?rev=68724&view=rev
Log:
[MSPAINT_NEW] save/restore certain settings to/from registry
Modified:
trunk/reactos/base/applications/mspaint_new/globalvar.h
trunk/reactos/base/applications/mspaint_new/history.cpp
trunk/reactos/base/applications/mspaint_new/imgarea.cpp
trunk/reactos/base/applications/mspaint_new/main.cpp
trunk/reactos/base/applications/mspaint_new/precomp.h
trunk/reactos/base/applications/mspaint_new/registry.cpp
trunk/reactos/base/applications/mspaint_new/registry.h
trunk/reactos/base/applications/mspaint_new/winproc.cpp
Modified: trunk/reactos/base/applications/mspaint_new/globalvar.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/globalvar.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/globalvar.h [iso-8859-1] Sun Aug 16
19:52:37 2015
@@ -19,6 +19,9 @@
extern int heightSetInDlg;
extern STRETCHSKEW stretchSkew;
+
+class RegistrySettings;
+extern RegistrySettings registrySettings;
class ImageModel;
extern ImageModel imageModel;
Modified: trunk/reactos/base/applications/mspaint_new/history.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/history.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/history.cpp [iso-8859-1] Sun Aug 16
19:52:37 2015
@@ -29,9 +29,9 @@
redoSteps = 0;
imageSaved = TRUE;
- // TODO: load dimensions from registry
- int imgXRes = 400;
- int imgYRes = 300;
+ // prepare a minimal usable bitmap
+ int imgXRes = 1;
+ int imgYRes = 1;
hDrawingDC = CreateCompatibleDC(NULL);
SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, paletteModel.GetFgColor()));
Modified: trunk/reactos/base/applications/mspaint_new/imgarea.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/imgarea.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/imgarea.cpp [iso-8859-1] Sun Aug 16
19:52:37 2015
@@ -12,7 +12,6 @@
#include "precomp.h"
#include "dialogs.h"
-#include "registry.h"
/* FUNCTIONS ********************************************************/
Modified: trunk/reactos/base/applications/mspaint_new/main.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/main.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/main.cpp [iso-8859-1] Sun Aug 16 19:52:37
2015
@@ -31,6 +31,8 @@
int textToolTextMaxLen = 0;
PaletteModel paletteModel;
+
+RegistrySettings registrySettings;
ImageModel imageModel;
BOOL askBeforeEnlarging = FALSE; // TODO: initialize from registry
@@ -134,13 +136,21 @@
_stprintf(progtitle, resstr, filename);
LoadString(hThisInstance, IDS_MINIATURETITLE, miniaturetitle,
SIZEOF(miniaturetitle));
+ /* load settings from registry */
+ registrySettings.Load();
+ showMiniature = registrySettings.ShowThumbnail;
+ imageModel.Crop(registrySettings.BMPWidth, registrySettings.BMPHeight);
+
/* create main window */
RECT mainWindowPos = {0, 0, 544, 375}; // FIXME: use equivalent of CW_USEDEFAULT for
position
hwnd = mainWindow.Create(HWND_DESKTOP, mainWindowPos, progtitle,
WS_OVERLAPPEDWINDOW);
- RECT miniaturePos = {180, 200, 180 + 120, 200 + 100};
+ RECT miniaturePos = {(LONG) registrySettings.ThumbXPos, (LONG)
registrySettings.ThumbYPos,
+ (LONG) registrySettings.ThumbXPos + (LONG)
registrySettings.ThumbWidth,
+ (LONG) registrySettings.ThumbYPos + (LONG)
registrySettings.ThumbHeight};
miniature.Create(hwnd, miniaturePos, miniaturetitle,
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
WS_EX_PALETTEWINDOW);
+ miniature.ShowWindow(showMiniature ? SW_SHOW : SW_HIDE);
/* loading and setting the window menu from resource */
menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
@@ -276,7 +286,7 @@
imageArea.SendMessage(WM_SIZE, 0, 0);
/* by moving the window, the things in WM_SIZE are done */
- MoveWindow(hwnd, 100, 100, 600, 450, TRUE);
+ mainWindow.SetWindowPlacement(&(registrySettings.WindowPlacement));
/* creating the text editor window for the text tool */
RECT textEditWindowPos = {300, 0, 300 + 300, 0 + 200};
@@ -299,6 +309,12 @@
DispatchMessage(&messages);
}
+ /* write back settings to registry */
+ registrySettings.ShowThumbnail = showMiniature;
+ registrySettings.BMPWidth = imageModel.GetWidth();
+ registrySettings.BMPHeight = imageModel.GetHeight();
+ registrySettings.Store();
+
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
Modified: trunk/reactos/base/applications/mspaint_new/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/precomp.h [iso-8859-1] Sun Aug 16 19:52:37
2015
@@ -28,6 +28,7 @@
#include "mouse.h"
#include "palette.h"
#include "palettemodel.h"
+#include "registry.h"
#include "scrollbox.h"
#include "selection.h"
#include "selectionmodel.h"
Modified: trunk/reactos/base/applications/mspaint_new/registry.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/registry.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/registry.cpp [iso-8859-1] Sun Aug 16
19:52:37 2015
@@ -14,8 +14,7 @@
/* FUNCTIONS ********************************************************/
-void
-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
{
HKEY hDesktop;
TCHAR szStyle[3], szTile[3];
@@ -42,3 +41,85 @@
RegCloseKey(hDesktop);
}
}
+
+void RegistrySettings::LoadPresets()
+{
+ BMPHeight = 300;
+ BMPWidth = 400;
+ GridExtent = 1;
+ NoStretching = 0;
+ ShowThumbnail = 0;
+ SnapToGrid = 0;
+ ThumbHeight = 100;
+ ThumbWidth = 120;
+ ThumbXPos = 180;
+ ThumbYPos = 200;
+ UnitSetting = 0;
+ const WINDOWPLACEMENT DefaultWindowPlacement = {
+ sizeof(WINDOWPLACEMENT),
+ 0,
+ SW_SHOWNORMAL,
+ {0, 0},
+ {-1, -1},
+ {100, 100, 700, 550}
+ };
+ WindowPlacement = DefaultWindowPlacement;
+}
+
+void RegistrySettings::Load()
+{
+ HKEY hView;
+ LoadPresets();
+ if (RegOpenKeyEx(HKEY_CURRENT_USER,
+
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\View"),
+ 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);
+ cbData = sizeof(WINDOWPLACEMENT);
+ RegQueryValueEx(hView, _T("WindowPlacement"), 0, NULL, (LPBYTE)
&WindowPlacement, &cbData);
+ }
+}
+
+void RegistrySettings::Store()
+{
+ HKEY hView;
+ if (RegCreateKeyEx(HKEY_CURRENT_USER,
+
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\View"),
+ 0, NULL, 0, KEY_READ | KEY_SET_VALUE, NULL, &hView, NULL) ==
ERROR_SUCCESS)
+ {
+ RegSetValueEx(hView, _T("BMPHeight"), 0, REG_DWORD, (LPBYTE)
&BMPHeight, sizeof(DWORD));
+ RegSetValueEx(hView, _T("BMPWidth"), 0, REG_DWORD, (LPBYTE)
&BMPWidth, sizeof(DWORD));
+ RegSetValueEx(hView, _T("GridExtent"), 0, REG_DWORD, (LPBYTE)
&GridExtent, sizeof(DWORD));
+ RegSetValueEx(hView, _T("NoStretching"), 0, REG_DWORD, (LPBYTE)
&NoStretching, sizeof(DWORD));
+ RegSetValueEx(hView, _T("ShowThumbnail"), 0, REG_DWORD, (LPBYTE)
&ShowThumbnail, sizeof(DWORD));
+ RegSetValueEx(hView, _T("SnapToGrid"), 0, REG_DWORD, (LPBYTE)
&SnapToGrid, sizeof(DWORD));
+ RegSetValueEx(hView, _T("ThumbHeight"), 0, REG_DWORD, (LPBYTE)
&ThumbHeight, sizeof(DWORD));
+ RegSetValueEx(hView, _T("ThumbWidth"), 0, REG_DWORD, (LPBYTE)
&ThumbWidth, sizeof(DWORD));
+ RegSetValueEx(hView, _T("ThumbXPos"), 0, REG_DWORD, (LPBYTE)
&ThumbXPos, sizeof(DWORD));
+ RegSetValueEx(hView, _T("ThumbYPos"), 0, REG_DWORD, (LPBYTE)
&ThumbYPos, sizeof(DWORD));
+ RegSetValueEx(hView, _T("UnitSetting"), 0, REG_DWORD, (LPBYTE)
&UnitSetting, sizeof(DWORD));
+ RegSetValueEx(hView, _T("WindowPlacement"), 0, REG_BINARY, (LPBYTE)
&WindowPlacement, sizeof(WINDOWPLACEMENT));
+ }
+}
Modified: trunk/reactos/base/applications/mspaint_new/registry.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/registry.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/registry.h [iso-8859-1] Sun Aug 16
19:52:37 2015
@@ -6,4 +6,27 @@
* PROGRAMMERS: Benedikt Freisen
*/
-void SetWallpaper(TCHAR *szFileName, DWORD dwStyle, DWORD dwTile);
+class RegistrySettings
+{
+private:
+ void LoadPresets();
+
+public:
+ DWORD BMPHeight;
+ DWORD BMPWidth;
+ DWORD GridExtent;
+ DWORD NoStretching;
+ DWORD ShowThumbnail;
+ DWORD SnapToGrid;
+ DWORD ThumbHeight;
+ DWORD ThumbWidth;
+ DWORD ThumbXPos;
+ DWORD ThumbYPos;
+ DWORD UnitSetting;
+ WINDOWPLACEMENT WindowPlacement;
+
+ static void SetWallpaper(TCHAR *szFileName, DWORD dwStyle, DWORD dwTile);
+
+ void Load();
+ void Store();
+};
Modified: trunk/reactos/base/applications/mspaint_new/winproc.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/winproc.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/winproc.cpp [iso-8859-1] Sun Aug 16
19:52:37 2015
@@ -12,7 +12,6 @@
#include "precomp.h"
#include "dialogs.h"
-#include "registry.h"
/* FUNCTIONS ********************************************************/
@@ -188,6 +187,7 @@
LRESULT CMainWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
+ GetWindowPlacement(&(registrySettings.WindowPlacement));
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
return 0;
}
@@ -428,13 +428,13 @@
GlobalFree(pd.hDevNames);
break;
case IDM_FILEASWALLPAPERPLANE:
- SetWallpaper(filepathname, 1, 1);
+ RegistrySettings::SetWallpaper(filepathname, 1, 1);
break;
case IDM_FILEASWALLPAPERCENTERED:
- SetWallpaper(filepathname, 1, 0);
+ RegistrySettings::SetWallpaper(filepathname, 1, 0);
break;
case IDM_FILEASWALLPAPERSTRETCHED:
- SetWallpaper(filepathname, 2, 0);
+ RegistrySettings::SetWallpaper(filepathname, 2, 0);
break;
case IDM_EDITUNDO:
imageModel.Undo();