ReactOS  0.4.15-dev-1177-g6cb3b62
RegistrySettings Class Reference

#include <registry.h>

Collaboration diagram for RegistrySettings:

Public Types

enum  WallpaperStyle { TILED, CENTERED, STRETCHED }
 

Public Member Functions

void Load ()
 
void Store ()
 
void SetMostRecentFile (LPCTSTR szPathName)
 

Static Public Member Functions

static void SetWallpaper (LPCTSTR szFileName, WallpaperStyle style)
 

Public Attributes

DWORD BMPHeight
 
DWORD BMPWidth
 
DWORD GridExtent
 
DWORD NoStretching
 
DWORD ShowThumbnail
 
DWORD SnapToGrid
 
DWORD ThumbHeight
 
DWORD ThumbWidth
 
DWORD ThumbXPos
 
DWORD ThumbYPos
 
DWORD UnitSetting
 
WINDOWPLACEMENT WindowPlacement
 
CString strFile1
 
CString strFile2
 
CString strFile3
 
CString strFile4
 

Private Member Functions

void LoadPresets ()
 

Detailed Description

Definition at line 11 of file registry.h.

Member Enumeration Documentation

◆ WallpaperStyle

Enumerator
TILED 
CENTERED 
STRETCHED 

Definition at line 35 of file registry.h.

Member Function Documentation

◆ Load()

void RegistrySettings::Load ( )

Definition at line 78 of file registry.cpp.

79 {
80  LoadPresets();
81 
82  CRegKey view;
83  if (view.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\View"), KEY_READ) == ERROR_SUCCESS)
84  {
85  ReadDWORD(view, _T("BMPHeight"), BMPHeight, TRUE);
86  ReadDWORD(view, _T("BMPWidth"), BMPWidth, TRUE);
87  ReadDWORD(view, _T("GridExtent"), GridExtent, FALSE);
88  ReadDWORD(view, _T("NoStretching"), NoStretching, FALSE);
89  ReadDWORD(view, _T("ShowThumbnail"), ShowThumbnail, FALSE);
90  ReadDWORD(view, _T("SnapToGrid"), SnapToGrid, FALSE);
91  ReadDWORD(view, _T("ThumbHeight"), ThumbHeight, TRUE);
92  ReadDWORD(view, _T("ThumbWidth"), ThumbWidth, TRUE);
93  ReadDWORD(view, _T("ThumbXPos"), ThumbXPos, TRUE);
94  ReadDWORD(view, _T("ThumbYPos"), ThumbYPos, TRUE);
95  ReadDWORD(view, _T("UnitSetting"), UnitSetting, FALSE);
96 
97  ULONG pnBytes = sizeof(WINDOWPLACEMENT);
98  view.QueryBinaryValue(_T("WindowPlacement"), &WindowPlacement, &pnBytes);
99  }
100 
101  CRegKey files;
102  if (files.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\Recent File List"), KEY_READ) == ERROR_SUCCESS)
103  {
104  ReadFileHistory(files, _T("File1"), strFile1);
105  ReadFileHistory(files, _T("File2"), strFile2);
106  ReadFileHistory(files, _T("File3"), strFile3);
107  ReadFileHistory(files, _T("File4"), strFile4);
108  }
109 }
DWORD ThumbXPos
Definition: registry.h:25
struct _WINDOWPLACEMENT WINDOWPLACEMENT
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD ThumbHeight
Definition: registry.h:23
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
CString strFile2
Definition: registry.h:31
DWORD BMPHeight
Definition: registry.h:17
#define FALSE
Definition: types.h:117
static void ReadFileHistory(CRegKey &key, LPCTSTR lpName, CString &strFile)
Definition: registry.cpp:31
DWORD NoStretching
Definition: registry.h:20
DWORD ShowThumbnail
Definition: registry.h:21
WINDOWPLACEMENT WindowPlacement
Definition: registry.h:28
#define _T(x)
Definition: vfdio.h:22
DWORD BMPWidth
Definition: registry.h:18
DWORD UnitSetting
Definition: registry.h:27
DWORD ThumbWidth
Definition: registry.h:24
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE)
Definition: atlbase.h:1070
static DWORD ReadDWORD(CRegKey &key, LPCTSTR lpName, DWORD &dwValue, BOOL bCheckForDef)
Definition: registry.cpp:18
DWORD ThumbYPos
Definition: registry.h:26
DWORD GridExtent
Definition: registry.h:19
CString strFile1
Definition: registry.h:30
CString strFile4
Definition: registry.h:33
DWORD SnapToGrid
Definition: registry.h:22
unsigned int ULONG
Definition: retypes.h:1
static IOleDocumentView * view
Definition: activex.c:1749
void LoadPresets()
Definition: registry.cpp:54
CString strFile3
Definition: registry.h:32

Referenced by _tWinMain().

◆ LoadPresets()

void RegistrySettings::LoadPresets ( )
private

Definition at line 54 of file registry.cpp.

55 {
56  BMPHeight = 300;
57  BMPWidth = 400;
58  GridExtent = 1;
59  NoStretching = 0;
60  ShowThumbnail = 0;
61  SnapToGrid = 0;
62  ThumbHeight = 100;
63  ThumbWidth = 120;
64  ThumbXPos = 180;
65  ThumbYPos = 200;
66  UnitSetting = 0;
67  const WINDOWPLACEMENT DefaultWindowPlacement = {
68  sizeof(WINDOWPLACEMENT),
69  0,
71  {0, 0},
72  {-1, -1},
73  {100, 100, 700, 550}
74  };
75  WindowPlacement = DefaultWindowPlacement;
76 }
DWORD ThumbXPos
Definition: registry.h:25
struct _WINDOWPLACEMENT WINDOWPLACEMENT
DWORD ThumbHeight
Definition: registry.h:23
DWORD BMPHeight
Definition: registry.h:17
DWORD NoStretching
Definition: registry.h:20
DWORD ShowThumbnail
Definition: registry.h:21
WINDOWPLACEMENT WindowPlacement
Definition: registry.h:28
DWORD BMPWidth
Definition: registry.h:18
DWORD UnitSetting
Definition: registry.h:27
DWORD ThumbWidth
Definition: registry.h:24
DWORD ThumbYPos
Definition: registry.h:26
DWORD GridExtent
Definition: registry.h:19
#define SW_SHOWNORMAL
Definition: winuser.h:764
DWORD SnapToGrid
Definition: registry.h:22

Referenced by Load().

◆ SetMostRecentFile()

void RegistrySettings::SetMostRecentFile ( LPCTSTR  szPathName)

Definition at line 146 of file registry.cpp.

147 {
148  if (szPathName && szPathName[0])
149  SHAddToRecentDocs(SHARD_PATHW, szPathName);
150 
151  if (strFile1 == szPathName)
152  {
153  // do nothing
154  }
155  else if (strFile2 == szPathName)
156  {
157  CString strTemp = strFile2;
158  strFile2 = strFile1;
159  strFile1 = strTemp;
160  }
161  else if (strFile3 == szPathName)
162  {
163  CString strTemp = strFile3;
164  strFile3 = strFile2;
165  strFile2 = strFile1;
166  strFile1 = strTemp;
167  }
168  else if (strFile4 == szPathName)
169  {
170  CString strTemp = strFile4;
171  strFile4 = strFile3;
172  strFile3 = strFile2;
173  strFile2 = strFile1;
174  strFile1 = strTemp;
175  }
176  else
177  {
178  strFile4 = strFile3;
179  strFile3 = strFile2;
180  strFile2 = strFile1;
181  strFile1 = szPathName;
182  }
183 }
CString strFile2
Definition: registry.h:31
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:809
CString strFile1
Definition: registry.h:30
CString strFile4
Definition: registry.h:33
#define SHARD_PATHW
Definition: shlobj.h:1103
CString strFile3
Definition: registry.h:32

Referenced by SaveDIBToFile(), and SetBitmapAndInfo().

◆ SetWallpaper()

void RegistrySettings::SetWallpaper ( LPCTSTR  szFileName,
RegistrySettings::WallpaperStyle  style 
)
static

Definition at line 40 of file registry.cpp.

41 {
42  CRegKey desktop;
43  if (desktop.Open(HKEY_CURRENT_USER, _T("Control Panel\\Desktop")) == ERROR_SUCCESS)
44  {
45  desktop.SetStringValue(_T("Wallpaper"), szFileName);
46 
47  desktop.SetStringValue(_T("WallpaperStyle"), (style == RegistrySettings::STRETCHED) ? _T("2") : _T("0"));
48  desktop.SetStringValue(_T("TileWallpaper"), (style == RegistrySettings::TILED) ? _T("1") : _T("0"));
49  }
50 
52 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SPI_SETDESKWALLPAPER
Definition: winuser.h:1351
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SystemParametersInfo
Definition: winuser.h:5833
#define _T(x)
Definition: vfdio.h:22
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE)
Definition: atlbase.h:1070
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
#define SPIF_SENDCHANGE
Definition: winuser.h:1554
Arabic default style
Definition: afstyles.h:93
LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType=REG_SZ)
Definition: atlbase.h:1224

Referenced by CMainWindow::OnCommand().

◆ Store()

void RegistrySettings::Store ( )

Definition at line 111 of file registry.cpp.

112 {
113  CRegKey view;
114  if (view.Create(HKEY_CURRENT_USER,
115  _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\View")) == ERROR_SUCCESS)
116  {
117  view.SetDWORDValue(_T("BMPHeight"), BMPHeight);
118  view.SetDWORDValue(_T("BMPWidth"), BMPWidth);
119  view.SetDWORDValue(_T("GridExtent"), GridExtent);
120  view.SetDWORDValue(_T("NoStretching"), NoStretching);
121  view.SetDWORDValue(_T("ShowThumbnail"), ShowThumbnail);
122  view.SetDWORDValue(_T("SnapToGrid"), SnapToGrid);
123  view.SetDWORDValue(_T("ThumbHeight"), ThumbHeight);
124  view.SetDWORDValue(_T("ThumbWidth"), ThumbWidth);
125  view.SetDWORDValue(_T("ThumbXPos"), ThumbXPos);
126  view.SetDWORDValue(_T("ThumbYPos"), ThumbYPos);
127  view.SetDWORDValue(_T("UnitSetting"), UnitSetting);
128 
129  view.SetBinaryValue(_T("WindowPlacement"), &WindowPlacement, sizeof(WINDOWPLACEMENT));
130  }
131 
132  CRegKey files;
133  if (files.Create(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\Recent File List")) == ERROR_SUCCESS)
134  {
135  if (!strFile1.IsEmpty())
136  files.SetStringValue(_T("File1"), strFile1);
137  if (!strFile2.IsEmpty())
138  files.SetStringValue(_T("File2"), strFile2);
139  if (!strFile3.IsEmpty())
140  files.SetStringValue(_T("File3"), strFile3);
141  if (!strFile4.IsEmpty())
142  files.SetStringValue(_T("File4"), strFile4);
143  }
144 }
DWORD ThumbXPos
Definition: registry.h:25
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD ThumbHeight
Definition: registry.h:23
#define HKEY_CURRENT_USER
Definition: winreg.h:11
CString strFile2
Definition: registry.h:31
DWORD BMPHeight
Definition: registry.h:17
DWORD NoStretching
Definition: registry.h:20
DWORD ShowThumbnail
Definition: registry.h:21
WINDOWPLACEMENT WindowPlacement
Definition: registry.h:28
#define _T(x)
Definition: vfdio.h:22
DWORD BMPWidth
Definition: registry.h:18
DWORD UnitSetting
Definition: registry.h:27
DWORD ThumbWidth
Definition: registry.h:24
LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass=REG_NONE, DWORD dwOptions=REG_OPTION_NON_VOLATILE, REGSAM samDesired=KEY_READ|KEY_WRITE, LPSECURITY_ATTRIBUTES lpSecAttr=NULL, LPDWORD lpdwDisposition=NULL)
Definition: atlbase.h:1091
DWORD ThumbYPos
Definition: registry.h:26
DWORD GridExtent
Definition: registry.h:19
CString strFile1
Definition: registry.h:30
CString strFile4
Definition: registry.h:33
bool IsEmpty() const
Definition: atlsimpstr.h:379
DWORD SnapToGrid
Definition: registry.h:22
static IOleDocumentView * view
Definition: activex.c:1749
LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType=REG_SZ)
Definition: atlbase.h:1224
CString strFile3
Definition: registry.h:32

Referenced by _tWinMain().

Member Data Documentation

◆ BMPHeight

DWORD RegistrySettings::BMPHeight

Definition at line 17 of file registry.h.

Referenced by _tWinMain(), Load(), LoadPresets(), SetBitmapAndInfo(), and Store().

◆ BMPWidth

DWORD RegistrySettings::BMPWidth

Definition at line 18 of file registry.h.

Referenced by _tWinMain(), Load(), LoadPresets(), SetBitmapAndInfo(), and Store().

◆ GridExtent

DWORD RegistrySettings::GridExtent

Definition at line 19 of file registry.h.

Referenced by Load(), LoadPresets(), and Store().

◆ NoStretching

DWORD RegistrySettings::NoStretching

Definition at line 20 of file registry.h.

Referenced by Load(), LoadPresets(), and Store().

◆ ShowThumbnail

DWORD RegistrySettings::ShowThumbnail

Definition at line 21 of file registry.h.

Referenced by _tWinMain(), Load(), LoadPresets(), and Store().

◆ SnapToGrid

DWORD RegistrySettings::SnapToGrid

Definition at line 22 of file registry.h.

Referenced by Load(), LoadPresets(), and Store().

◆ strFile1

CString RegistrySettings::strFile1

◆ strFile2

CString RegistrySettings::strFile2

◆ strFile3

CString RegistrySettings::strFile3

◆ strFile4

CString RegistrySettings::strFile4

◆ ThumbHeight

DWORD RegistrySettings::ThumbHeight

Definition at line 23 of file registry.h.

Referenced by _tWinMain(), Load(), LoadPresets(), and Store().

◆ ThumbWidth

DWORD RegistrySettings::ThumbWidth

Definition at line 24 of file registry.h.

Referenced by _tWinMain(), Load(), LoadPresets(), and Store().

◆ ThumbXPos

DWORD RegistrySettings::ThumbXPos

Definition at line 25 of file registry.h.

Referenced by _tWinMain(), Load(), LoadPresets(), and Store().

◆ ThumbYPos

DWORD RegistrySettings::ThumbYPos

Definition at line 26 of file registry.h.

Referenced by _tWinMain(), Load(), LoadPresets(), and Store().

◆ UnitSetting

DWORD RegistrySettings::UnitSetting

Definition at line 27 of file registry.h.

Referenced by Load(), LoadPresets(), and Store().

◆ WindowPlacement

WINDOWPLACEMENT RegistrySettings::WindowPlacement

Definition at line 28 of file registry.h.

Referenced by _tWinMain(), Load(), LoadPresets(), CMainWindow::OnDestroy(), and Store().


The documentation for this class was generated from the following files: