ReactOS  0.4.15-dev-3745-g356babc
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
 
CString strFontName
 
DWORD PointSize
 
DWORD Bold
 
DWORD Italic
 
DWORD Underline
 
DWORD CharSet
 
DWORD FontsPositionX
 
DWORD FontsPositionY
 
DWORD ShowTextTool
 

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 45 of file registry.h.

Member Function Documentation

◆ Load()

void RegistrySettings::Load ( )

Definition at line 85 of file registry.cpp.

86 {
87  LoadPresets();
88 
89  CRegKey view;
90  if (view.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\View"), KEY_READ) == ERROR_SUCCESS)
91  {
92  ReadDWORD(view, _T("BMPHeight"), BMPHeight, TRUE);
93  ReadDWORD(view, _T("BMPWidth"), BMPWidth, TRUE);
94  ReadDWORD(view, _T("GridExtent"), GridExtent, FALSE);
95  ReadDWORD(view, _T("NoStretching"), NoStretching, FALSE);
96  ReadDWORD(view, _T("ShowThumbnail"), ShowThumbnail, FALSE);
97  ReadDWORD(view, _T("SnapToGrid"), SnapToGrid, FALSE);
98  ReadDWORD(view, _T("ThumbHeight"), ThumbHeight, TRUE);
99  ReadDWORD(view, _T("ThumbWidth"), ThumbWidth, TRUE);
100  ReadDWORD(view, _T("ThumbXPos"), ThumbXPos, TRUE);
101  ReadDWORD(view, _T("ThumbYPos"), ThumbYPos, TRUE);
102  ReadDWORD(view, _T("UnitSetting"), UnitSetting, FALSE);
103 
104  ULONG pnBytes = sizeof(WINDOWPLACEMENT);
105  view.QueryBinaryValue(_T("WindowPlacement"), &WindowPlacement, &pnBytes);
106  }
107 
108  CRegKey files;
109  if (files.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\Recent File List"), KEY_READ) == ERROR_SUCCESS)
110  {
111  ReadString(files, _T("File1"), strFile1);
112  ReadString(files, _T("File2"), strFile2);
113  ReadString(files, _T("File3"), strFile3);
114  ReadString(files, _T("File4"), strFile4);
115  }
116 
117  CRegKey text;
118  if (text.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\Text"), KEY_READ) == ERROR_SUCCESS)
119  {
120  ReadDWORD(text, _T("Bold"), Bold, FALSE);
121  ReadDWORD(text, _T("Italic"), Italic, FALSE);
122  ReadDWORD(text, _T("Underline"), Underline, FALSE);
123  ReadDWORD(text, _T("CharSet"), CharSet, FALSE);
124  ReadDWORD(text, _T("PointSize"), PointSize, FALSE);
125  ReadDWORD(text, _T("PositionX"), FontsPositionX, FALSE);
126  ReadDWORD(text, _T("PositionY"), FontsPositionY, FALSE);
127  ReadDWORD(text, _T("ShowTextTool"), ShowTextTool, FALSE);
128  ReadString(text, _T("TypeFaceName"), strFontName, strFontName);
129  }
130 
131  // Fix the bitmap size if too large
132  if (BMPWidth > 5000)
133  BMPWidth = (GetSystemMetrics(SM_CXSCREEN) * 6) / 10;
134  if (BMPHeight > 5000)
135  BMPHeight = (GetSystemMetrics(SM_CYSCREEN) * 6) / 10;
136 }
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
const WCHAR * text
Definition: package.c:1834
#define HKEY_CURRENT_USER
Definition: winreg.h:11
CString strFile2
Definition: registry.h:31
CString strFontName
Definition: registry.h:35
DWORD BMPHeight
Definition: registry.h:17
#define SM_CXSCREEN
Definition: winuser.h:953
#define FALSE
Definition: types.h:117
DWORD NoStretching
Definition: registry.h:20
DWORD ShowThumbnail
Definition: registry.h:21
static void ReadString(CRegKey &key, LPCTSTR lpName, CString &strValue, LPCTSTR lpDefault=TEXT(""))
Definition: registry.cpp:28
DWORD ShowTextTool
Definition: registry.h:43
WINDOWPLACEMENT WindowPlacement
Definition: registry.h:28
DWORD FontsPositionY
Definition: registry.h:42
#define SM_CYSCREEN
Definition: winuser.h:954
#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:1072
int WINAPI GetSystemMetrics(_In_ int)
DWORD PointSize
Definition: registry.h:36
DWORD FontsPositionX
Definition: registry.h:41
DWORD Underline
Definition: registry.h:39
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:56
CString strFile3
Definition: registry.h:32

Referenced by _tWinMain().

◆ LoadPresets()

void RegistrySettings::LoadPresets ( )
private

Definition at line 56 of file registry.cpp.

57 {
60  GridExtent = 1;
61  NoStretching = 0;
62  ShowThumbnail = 0;
63  SnapToGrid = 0;
64  ThumbHeight = 100;
65  ThumbWidth = 120;
66  ThumbXPos = 180;
67  ThumbYPos = 200;
68  UnitSetting = 0;
69  Bold = FALSE;
70  Italic = FALSE;
71  Underline = FALSE;
73  PointSize = 14;
74  FontsPositionX = 0;
75  FontsPositionY = 0;
77 
78  LOGFONT lf;
79  GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
81 
83 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
DWORD ThumbXPos
Definition: registry.h:25
DWORD ThumbHeight
Definition: registry.h:23
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1664
CString strFontName
Definition: registry.h:35
#define DEFAULT_CHARSET
Definition: wingdi.h:384
DWORD BMPHeight
Definition: registry.h:17
#define SM_CXSCREEN
Definition: winuser.h:953
#define FALSE
Definition: types.h:117
DWORD NoStretching
Definition: registry.h:20
DWORD ShowThumbnail
Definition: registry.h:21
DWORD ShowTextTool
Definition: registry.h:43
WINDOWPLACEMENT WindowPlacement
Definition: registry.h:28
DWORD FontsPositionY
Definition: registry.h:42
#define SM_CYSCREEN
Definition: winuser.h:954
DWORD BMPWidth
Definition: registry.h:18
DWORD UnitSetting
Definition: registry.h:27
DWORD ThumbWidth
Definition: registry.h:24
int WINAPI GetSystemMetrics(_In_ int)
DWORD PointSize
Definition: registry.h:36
#define GetObject
Definition: wingdi.h:4468
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
DWORD FontsPositionX
Definition: registry.h:41
DWORD Underline
Definition: registry.h:39
DWORD ThumbYPos
Definition: registry.h:26
DWORD GridExtent
Definition: registry.h:19
DWORD SnapToGrid
Definition: registry.h:22
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55

Referenced by Load().

◆ SetMostRecentFile()

void RegistrySettings::SetMostRecentFile ( LPCTSTR  szPathName)

Definition at line 187 of file registry.cpp.

188 {
189  if (szPathName && szPathName[0])
190  SHAddToRecentDocs(SHARD_PATHW, szPathName);
191 
192  if (strFile1 == szPathName)
193  {
194  // do nothing
195  }
196  else if (strFile2 == szPathName)
197  {
198  CString strTemp = strFile2;
199  strFile2 = strFile1;
200  strFile1 = strTemp;
201  }
202  else if (strFile3 == szPathName)
203  {
204  CString strTemp = strFile3;
205  strFile3 = strFile2;
206  strFile2 = strFile1;
207  strFile1 = strTemp;
208  }
209  else if (strFile4 == szPathName)
210  {
211  CString strTemp = strFile4;
212  strFile4 = strFile3;
213  strFile3 = strFile2;
214  strFile2 = strFile1;
215  strFile1 = strTemp;
216  }
217  else
218  {
219  strFile4 = strFile3;
220  strFile3 = strFile2;
221  strFile2 = strFile1;
222  strFile1 = szPathName;
223  }
224 }
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 42 of file registry.cpp.

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

Referenced by CMainWindow::OnCommand().

◆ Store()

void RegistrySettings::Store ( )

Definition at line 138 of file registry.cpp.

139 {
140  CRegKey view;
141  if (view.Create(HKEY_CURRENT_USER,
142  _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\View")) == ERROR_SUCCESS)
143  {
144  view.SetDWORDValue(_T("BMPHeight"), BMPHeight);
145  view.SetDWORDValue(_T("BMPWidth"), BMPWidth);
146  view.SetDWORDValue(_T("GridExtent"), GridExtent);
147  view.SetDWORDValue(_T("NoStretching"), NoStretching);
148  view.SetDWORDValue(_T("ShowThumbnail"), ShowThumbnail);
149  view.SetDWORDValue(_T("SnapToGrid"), SnapToGrid);
150  view.SetDWORDValue(_T("ThumbHeight"), ThumbHeight);
151  view.SetDWORDValue(_T("ThumbWidth"), ThumbWidth);
152  view.SetDWORDValue(_T("ThumbXPos"), ThumbXPos);
153  view.SetDWORDValue(_T("ThumbYPos"), ThumbYPos);
154  view.SetDWORDValue(_T("UnitSetting"), UnitSetting);
155 
156  view.SetBinaryValue(_T("WindowPlacement"), &WindowPlacement, sizeof(WINDOWPLACEMENT));
157  }
158 
159  CRegKey files;
160  if (files.Create(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\Recent File List")) == ERROR_SUCCESS)
161  {
162  if (!strFile1.IsEmpty())
163  files.SetStringValue(_T("File1"), strFile1);
164  if (!strFile2.IsEmpty())
165  files.SetStringValue(_T("File2"), strFile2);
166  if (!strFile3.IsEmpty())
167  files.SetStringValue(_T("File3"), strFile3);
168  if (!strFile4.IsEmpty())
169  files.SetStringValue(_T("File4"), strFile4);
170  }
171 
172  CRegKey text;
173  if (text.Create(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint\\Text")) == ERROR_SUCCESS)
174  {
175  text.SetDWORDValue(_T("Bold"), Bold);
176  text.SetDWORDValue(_T("Italic"), Italic);
177  text.SetDWORDValue(_T("Underline"), Underline);
178  text.SetDWORDValue(_T("CharSet"), CharSet);
179  text.SetDWORDValue(_T("PointSize"), PointSize);
180  text.SetDWORDValue(_T("PositionX"), FontsPositionX);
181  text.SetDWORDValue(_T("PositionY"), FontsPositionY);
182  text.SetDWORDValue(_T("ShowTextTool"), ShowTextTool);
183  text.SetStringValue(_T("TypeFaceName"), strFontName);
184  }
185 }
DWORD ThumbXPos
Definition: registry.h:25
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD ThumbHeight
Definition: registry.h:23
const WCHAR * text
Definition: package.c:1834
#define HKEY_CURRENT_USER
Definition: winreg.h:11
CString strFile2
Definition: registry.h:31
CString strFontName
Definition: registry.h:35
DWORD BMPHeight
Definition: registry.h:17
DWORD NoStretching
Definition: registry.h:20
DWORD ShowThumbnail
Definition: registry.h:21
DWORD ShowTextTool
Definition: registry.h:43
WINDOWPLACEMENT WindowPlacement
Definition: registry.h:28
DWORD FontsPositionY
Definition: registry.h:42
#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
DWORD PointSize
Definition: registry.h:36
DWORD FontsPositionX
Definition: registry.h:41
DWORD Underline
Definition: registry.h:39
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:1093
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:1226
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().

◆ Bold

DWORD RegistrySettings::Bold

◆ CharSet

DWORD RegistrySettings::CharSet

Definition at line 40 of file registry.h.

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

◆ FontsPositionX

DWORD RegistrySettings::FontsPositionX

Definition at line 41 of file registry.h.

Referenced by Load(), LoadPresets(), CFontsDialog::OnInitDialog(), CFontsDialog::OnMove(), and Store().

◆ FontsPositionY

DWORD RegistrySettings::FontsPositionY

Definition at line 42 of file registry.h.

Referenced by Load(), LoadPresets(), CFontsDialog::OnInitDialog(), CFontsDialog::OnMove(), and Store().

◆ GridExtent

DWORD RegistrySettings::GridExtent

Definition at line 19 of file registry.h.

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

◆ Italic

DWORD RegistrySettings::Italic

◆ NoStretching

DWORD RegistrySettings::NoStretching

Definition at line 20 of file registry.h.

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

◆ PointSize

DWORD RegistrySettings::PointSize

◆ ShowTextTool

DWORD RegistrySettings::ShowTextTool

◆ 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

◆ strFontName

CString RegistrySettings::strFontName

◆ 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().

◆ Underline

DWORD RegistrySettings::Underline

◆ 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: