ReactOS  0.4.13-dev-259-g5ca9c9c
settings.c File Reference
#include <windows.h>
#include <tchar.h>
#include <commctrl.h>
#include <shellapi.h>
#include "resource.h"
#include "settings.h"
Include dependency graph for settings.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 
#define SIZEOF(_v)   (sizeof(_v) / sizeof(*_v))
 

Functions

static DWORD QueryDWORD (HKEY hKey, LPCTSTR pszValueName, DWORD Default)
 
static void SaveDWORD (HKEY hKey, LPCTSTR pszValueName, DWORD dwValue)
 
void LoadSettings (void)
 
void SaveSettings (void)
 
static void SetupControls (HWND hWnd)
 
static void ApplySettings (HWND hWnd)
 
static void ReadSettings (HWND hWnd)
 
static BOOL OnCommandAbout (HWND hWnd)
 
BOOL CALLBACK ScreenSaverConfigureDialog (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI RegisterDialogClasses (HANDLE hInst)
 

Variables

SSSTARS Settings
 
static const SSSTARS FactoryDefaults
 
static const DWORD RotoStrings []
 

Macro Definition Documentation

◆ SIZEOF

#define SIZEOF (   _v)    (sizeof(_v) / sizeof(*_v))

Definition at line 30 of file settings.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 21 of file settings.c.

Function Documentation

◆ ApplySettings()

static void ApplySettings ( HWND  hWnd)
static

Definition at line 236 of file settings.c.

237 {
240 
243 
245 
250 }
#define TRUE
Definition: types.h:120
#define IDC_TEXT_SPEED
Definition: resource.h:17
HWND hWnd
Definition: settings.c:17
#define TBM_SETPOS
Definition: commctrl.h:2008
SSSTARS Settings
Definition: settings.c:33
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5708
DWORD bSmoothShading
Definition: settings.h:42
#define IDC_SLIDER_NUM_OF_STARS
Definition: resource.h:14
#define IDC_CHECK_DOBLENDING
Definition: resource.h:22
#define BM_SETCHECK
Definition: winuser.h:1882
#define IDC_COMBO_ROTATION
Definition: resource.h:18
DWORD bFinePerspective
Definition: settings.h:40
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define CB_SETCURSEL
Definition: winuser.h:1922
#define IDC_TEXT_NUM_OF_STARS
Definition: resource.h:16
#define IDC_SLIDER_SPEED
Definition: resource.h:15
#define IDC_CHECK_SHADING
Definition: resource.h:25
DWORD uiNumStars
Definition: settings.h:36
DWORD uiSpeed
Definition: settings.h:37
DWORD bDoBlending
Definition: settings.h:39
#define IDC_CHECK_PERSPECTIVE
Definition: resource.h:23
DWORD uiRotation
Definition: settings.h:38
#define IDC_CHECK_FILTERING
Definition: resource.h:24
DWORD bEnableFiltering
Definition: settings.h:41

Referenced by ScreenSaverConfigureDialog().

◆ LoadSettings()

void LoadSettings ( void  )

Definition at line 81 of file settings.c.

82 {
83  HKEY hKey;
84  LONG lRes;
85 
87 
88  lRes = RegCreateKeyEx(
90  _T("Software\\Microsoft\\ScreenSavers\\Ssstars"),
91  0,
92  _T(""),
93  0,
94  KEY_READ,
95  NULL,
96  &hKey,
97  NULL);
98 
99  if (lRes != ERROR_SUCCESS)
100  return;
101 
102  Settings.uiNumStars = QueryDWORD(hKey, _T("NumberOfStars"), Settings.uiNumStars);
103  Settings.uiSpeed = QueryDWORD(hKey, _T("Speed"), Settings.uiSpeed);
104  Settings.uiRotation = QueryDWORD(hKey, _T("TypeOfRotation"), Settings.uiRotation);
105 
106  Settings.bDoBlending = QueryDWORD(hKey, _T("DoBlending"), Settings.bDoBlending);
107  Settings.bFinePerspective = QueryDWORD(hKey, _T("FinePerspective"), Settings.bFinePerspective);
108  Settings.bEnableFiltering = QueryDWORD(hKey, _T("EnableFiltering"), Settings.bEnableFiltering);
109  Settings.bSmoothShading = QueryDWORD(hKey, _T("SmoothShading"), Settings.bSmoothShading);
110 
111  // Check the number of stars to be in range
114  else
117 
118  // Check the speed to be in range
119  if (Settings.uiSpeed < MIN_SPEED)
121  else
122  if (Settings.uiSpeed > MAX_SPEED)
124 
125  // Check type of rotation to be in range
130 
131  RegCloseKey(hKey);
132 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static const SSSTARS FactoryDefaults
Definition: settings.c:36
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define ROTATION_NONE
Definition: settings.h:24
#define MAX_SPEED
Definition: settings.h:33
SSSTARS Settings
Definition: settings.c:33
#define ROTATION_LINEAR
Definition: settings.h:25
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
DWORD bSmoothShading
Definition: settings.h:42
smooth NULL
Definition: ftsmooth.c:416
#define MIN_STARS
Definition: settings.h:29
#define _T(x)
Definition: vfdio.h:22
DWORD bFinePerspective
Definition: settings.h:40
#define MAX_STARS
Definition: settings.h:30
#define MIN_SPEED
Definition: settings.h:32
DWORD uiNumStars
Definition: settings.h:36
DWORD uiSpeed
Definition: settings.h:37
DWORD bDoBlending
Definition: settings.h:39
static DWORD QueryDWORD(HKEY hKey, LPCTSTR pszValueName, DWORD Default)
Definition: settings.c:53
#define ROTATION_PERIODIC
Definition: settings.h:26
DWORD uiRotation
Definition: settings.h:38
DWORD bEnableFiltering
Definition: settings.h:41
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by InitDevice(), InitInstance(), MAIN_LoadSettings(), OnCreate(), ScreenSaverConfigureDialog(), ScreenSaverProc(), and wWinMain().

◆ OnCommandAbout()

static BOOL OnCommandAbout ( HWND  hWnd)
static

Definition at line 268 of file settings.c.

269 {
271  HICON hIcon;
272  TCHAR szAppName[256];
273  TCHAR szAuthor[256];
274  TCHAR szLicense[1024];
275 
277 
279 
281  LoadString(hInstance, IDS_AUTHOR, szAuthor, SIZEOF(szAuthor));
282  LoadString(hInstance, IDS_LICENSE, szLicense, SIZEOF(szLicense));
283 
284  _tcscat(szAppName, _T("#"));
285  _tcscat(szAppName, szAuthor);
286 
287  ShellAbout(hWnd, szAppName, szLicense, hIcon);
288 
289  return TRUE;
290 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define IDI_STARFIELD
Definition: resource.h:9
#define IDS_DESCRIPTION
Definition: resource.h:92
HWND hWnd
Definition: settings.c:17
HINSTANCE hInstance
Definition: charmap.c:20
char TCHAR
Definition: xmlstorage.h:189
#define SIZEOF(_v)
Definition: settings.c:30
#define _T(x)
Definition: vfdio.h:22
#define IDS_AUTHOR
Definition: resource.h:10
#define ShellAbout
Definition: shellapi.h:688
HANDLE HINSTANCE
Definition: typedefs.h:75
TCHAR szAppName[128]
Definition: solitaire.cpp:16
#define IDS_LICENSE
Definition: resource.h:28
HICON hIcon
Definition: msconfig.c:44
#define GWLP_HINSTANCE
Definition: winuser.h:850
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
#define LoadIcon
Definition: winuser.h:5679
#define GetWindowLongPtr
Definition: treelist.c:73
#define LoadString
Definition: winuser.h:5685

Referenced by ScreenSaverConfigureDialog().

◆ QueryDWORD()

static DWORD QueryDWORD ( HKEY  hKey,
LPCTSTR  pszValueName,
DWORD  Default 
)
static

Definition at line 53 of file settings.c.

54 {
55  DWORD dwData, dwType, cbData;
56  LONG lRes;
57 
58  dwType = REG_DWORD;
59  cbData = sizeof(DWORD);
60 
61  lRes = RegQueryValueEx(
62  hKey,
63  pszValueName,
64  NULL,
65  &dwType,
66  (LPBYTE)&dwData,
67  &cbData);
68 
69  if (lRes != ERROR_SUCCESS || dwType != REG_DWORD)
70  return Default;
71 
72  return dwData;
73 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define DWORD
Definition: nt_native.h:44
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by LoadSettings().

◆ ReadSettings()

static void ReadSettings ( HWND  hWnd)
static

Definition at line 252 of file settings.c.

253 {
256 
259 
261 
266 }
#define IDC_TEXT_SPEED
Definition: resource.h:17
HWND hWnd
Definition: settings.c:17
SSSTARS Settings
Definition: settings.c:33
#define SendDlgItemMessage
Definition: winuser.h:5708
#define CB_GETCURSEL
Definition: winuser.h:1904
#define TBM_GETPOS
Definition: commctrl.h:2003
DWORD bSmoothShading
Definition: settings.h:42
#define IDC_SLIDER_NUM_OF_STARS
Definition: resource.h:14
#define IDC_CHECK_DOBLENDING
Definition: resource.h:22
#define BM_GETCHECK
Definition: winuser.h:1879
#define IDC_COMBO_ROTATION
Definition: resource.h:18
DWORD bFinePerspective
Definition: settings.h:40
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define IDC_TEXT_NUM_OF_STARS
Definition: resource.h:16
#define IDC_SLIDER_SPEED
Definition: resource.h:15
#define IDC_CHECK_SHADING
Definition: resource.h:25
DWORD uiNumStars
Definition: settings.h:36
DWORD uiSpeed
Definition: settings.h:37
DWORD bDoBlending
Definition: settings.h:39
#define IDC_CHECK_PERSPECTIVE
Definition: resource.h:23
DWORD uiRotation
Definition: settings.h:38
#define IDC_CHECK_FILTERING
Definition: resource.h:24
DWORD bEnableFiltering
Definition: settings.h:41

Referenced by ScreenSaverConfigureDialog().

◆ RegisterDialogClasses()

BOOL WINAPI RegisterDialogClasses ( HANDLE  hInst)

Definition at line 329 of file settings.c.

330 {
332 
333  return TRUE;
334 }
#define TRUE
Definition: types.h:120
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863

◆ SaveDWORD()

static void SaveDWORD ( HKEY  hKey,
LPCTSTR  pszValueName,
DWORD  dwValue 
)
static

Definition at line 75 of file settings.c.

76 {
77  RegSetValueEx(hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue));
78 }
unsigned char * LPBYTE
Definition: typedefs.h:52
#define REG_DWORD
Definition: sdbapi.c:596
#define RegSetValueEx
Definition: winreg.h:533

Referenced by SaveSettings().

◆ SaveSettings()

void SaveSettings ( void  )

Definition at line 134 of file settings.c.

135 {
136  HKEY hKey;
137  LONG lRes;
138 
139  lRes = RegCreateKeyEx(
141  _T("Software\\Microsoft\\ScreenSavers\\Ssstars"),
142  0,
143  _T(""),
144  0,
145  KEY_WRITE,
146  NULL,
147  &hKey,
148  NULL);
149 
150  if (lRes != ERROR_SUCCESS)
151  return;
152 
153  SaveDWORD(hKey, _T("NumberOfStars"), Settings.uiNumStars);
154  SaveDWORD(hKey, _T("Speed"), Settings.uiSpeed);
155  SaveDWORD(hKey, _T("TypeOfRotation"), Settings.uiRotation);
156 
157  SaveDWORD(hKey, _T("DoBlending"), Settings.bDoBlending);
158  SaveDWORD(hKey, _T("FinePerspective"), Settings.bFinePerspective);
159  SaveDWORD(hKey, _T("EnableFiltering"), Settings.bEnableFiltering);
160  SaveDWORD(hKey, _T("SmoothShading"), Settings.bSmoothShading);
161 
162  RegCloseKey(hKey);
163 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
SSSTARS Settings
Definition: settings.c:33
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
DWORD bSmoothShading
Definition: settings.h:42
smooth NULL
Definition: ftsmooth.c:416
static void SaveDWORD(HKEY hKey, LPCTSTR pszValueName, DWORD dwValue)
Definition: settings.c:75
#define KEY_WRITE
Definition: nt_native.h:1031
#define _T(x)
Definition: vfdio.h:22
DWORD bFinePerspective
Definition: settings.h:40
DWORD uiNumStars
Definition: settings.h:36
DWORD uiSpeed
Definition: settings.h:37
DWORD bDoBlending
Definition: settings.h:39
DWORD uiRotation
Definition: settings.h:38
DWORD bEnableFiltering
Definition: settings.h:41
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by ConfigDlgProc(), FrameWndProc(), GuiApplyUserSettings(), PanelWndProc(), CMainWindow::ProcessWindowMessage(), ScreenSaverConfigureDialog(), anonymous_namespace{settingsdlg.cpp}::SettingsDlgProc(), and WndProc().

◆ ScreenSaverConfigureDialog()

BOOL CALLBACK ScreenSaverConfigureDialog ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 295 of file settings.c.

296 {
297  switch (uMsg) {
298  case WM_INITDIALOG:
299  LoadSettings();
300  SetupControls(hDlg);
301  ApplySettings(hDlg);
302  return TRUE;
303 
304  case WM_COMMAND:
305  switch (LOWORD( wParam )) {
306 
307  case IDOK:
308  // Write configuration
309  SaveSettings();
310 
311  // Fall down...
312  case IDCANCEL:
313  EndDialog( hDlg, LOWORD( wParam ));
314  return TRUE;
315 
316  case IDC_BUTTON_ABOUT:
317  return OnCommandAbout(hDlg);
318  }
319 
320  case WM_HSCROLL:
321  ReadSettings(hDlg);
322  return TRUE;
323 
324  }
325 
326  return FALSE;
327 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
static void SetupControls(HWND hWnd)
Definition: settings.c:165
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
static BOOL OnCommandAbout(HWND hWnd)
Definition: settings.c:268
void SaveSettings(void)
Definition: settings.c:113
static void ReadSettings(HWND hWnd)
Definition: settings.c:252
#define WM_COMMAND
Definition: winuser.h:1716
#define WM_HSCROLL
Definition: winuser.h:1719
#define IDCANCEL
Definition: winuser.h:825
#define IDC_BUTTON_ABOUT
Definition: resource.h:20
static void ApplySettings(HWND hWnd)
Definition: settings.c:236
#define WM_INITDIALOG
Definition: winuser.h:1715
#define LOWORD(l)
Definition: pedump.c:82
void LoadSettings(void)
Definition: settings.c:53

◆ SetupControls()

static void SetupControls ( HWND  hWnd)
static

Definition at line 165 of file settings.c.

166 {
167  TCHAR Strings[256];
169  UINT x, gap;
170  LOGFONT lf;
171  HFONT hFont;
172  HBITMAP hCosmos;
173  HDC hDC, hMemDC;
174  HGDIOBJ hOldBmp, hOldFnt;
175  SIZE sizeReactOS;
176  SIZE sizeStarfield;
177  BITMAP bm;
178 
180 
182 
184 
185  for (x = 0; x < ROTATION_ITEMS; x++)
186  {
187  LoadString(hInstance, RotoStrings[x], Strings, sizeof(Strings)/sizeof(TCHAR));
189  }
190 
192 
193  hDC = GetDC(hWnd);
194  hMemDC = CreateCompatibleDC(hDC);
195 
196  // Create the font for the title
197  ZeroMemory(&lf, sizeof(lf));
198 
199  lf.lfWeight = FW_THIN;
200  lf.lfCharSet = ANSI_CHARSET;
202  lf.lfHeight = 36;
203  _tcscpy(lf.lfFaceName, _T("Tahoma"));
204 
205  hFont = CreateFontIndirect(&lf);
206 
207  hOldBmp = SelectObject(hMemDC, hCosmos);
208  hOldFnt = SelectObject(hMemDC, hFont);
209 
210  SetBkMode(hMemDC, TRANSPARENT);
211  SetTextColor(hMemDC, RGB(0xFF, 0xFF, 0xFF));
212 
213  x = LoadString(hInstance, IDS_DESCRIPTION, Strings, sizeof(Strings)/sizeof(TCHAR));
214 
215  GetTextExtentPoint32(hMemDC, _T("ReactOS"), 7, &sizeReactOS);
216  GetTextExtentPoint32(hMemDC, Strings, x, &sizeStarfield);
217 
218  GetObject(hCosmos, sizeof(BITMAP), &bm);
219 
220  gap = bm.bmHeight - sizeReactOS.cy - sizeStarfield.cy;
221 
222  TextOut(hMemDC, 16, gap * 2 / 5, _T("ReactOS"), 7);
223  TextOut(hMemDC, 16, gap * 3 / 5 + sizeReactOS.cy, Strings, x);
224 
225  SelectObject(hMemDC, hOldBmp);
226  SelectObject(hMemDC, hOldFnt);
227 
229 
230  DeleteDC(hMemDC);
231  ReleaseDC(hWnd, hDC);
232 
234 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
HDC WINAPI GetDC(_In_opt_ HWND)
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
#define IDS_DESCRIPTION
Definition: resource.h:92
static HDC
Definition: imagelist.c:92
#define TBM_SETRANGE
Definition: commctrl.h:2009
HWND hWnd
Definition: settings.c:17
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BYTE lfCharSet
Definition: dimm.idl:50
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SendDlgItemMessage
Definition: winuser.h:5708
#define PROOF_QUALITY
Definition: wingdi.h:437
#define IDB_COSMOS
Definition: resource.h:11
HFONT hFont
Definition: main.c:53
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
HINSTANCE hInstance
Definition: charmap.c:20
LONG lfHeight
Definition: dimm.idl:42
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define IDC_SLIDER_NUM_OF_STARS
Definition: resource.h:14
#define TRANSPARENT
Definition: wingdi.h:949
#define CB_ADDSTRING
Definition: winuser.h:1897
LONG lfWeight
Definition: dimm.idl:46
#define MIN_STARS
Definition: settings.h:29
LONG_PTR LPARAM
Definition: windef.h:208
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
#define IDC_IMAGE_COSMOS
Definition: resource.h:19
#define RGB(r, g, b)
Definition: wingdi.h:2918
#define IDC_COMBO_ROTATION
Definition: resource.h:18
#define FW_THIN
Definition: wingdi.h:368
static const WCHAR Strings[]
Definition: reg.c:35
#define GetObject
Definition: wingdi.h:4446
HANDLE HINSTANCE
Definition: typedefs.h:75
#define ROTATION_ITEMS
Definition: settings.h:27
#define MAX_STARS
Definition: settings.h:30
#define IDC_SLIDER_SPEED
Definition: resource.h:15
BYTE lfQuality
Definition: dimm.idl:53
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:886
static HDC hDC
Definition: 3dtext.c:33
static const DWORD RotoStrings[]
Definition: settings.c:47
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1331
#define LR_CREATEDIBSECTION
Definition: winuser.h:1088
#define CreateFontIndirect
Definition: wingdi.h:4422
unsigned int UINT
Definition: ndis.h:50
#define IMAGE_BITMAP
Definition: winuser.h:211
#define STM_SETIMAGE
Definition: winuser.h:2054
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define GWLP_HINSTANCE
Definition: winuser.h:850
#define GetTextExtentPoint32
Definition: wingdi.h:4450
#define TextOut
Definition: wingdi.h:4461
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
#define LoadImage
Definition: winuser.h:5681
static HBITMAP
Definition: button.c:44
#define GetWindowLongPtr
Definition: treelist.c:73
#define ANSI_CHARSET
Definition: wingdi.h:382
LONG cy
Definition: windef.h:320
#define LoadString
Definition: winuser.h:5685

Referenced by ScreenSaverConfigureDialog().

Variable Documentation

◆ FactoryDefaults

const SSSTARS FactoryDefaults
static
Initial value:
= {
20,
}
#define TRUE
Definition: types.h:120
#define MAX_STARS
Definition: settings.h:30
#define ROTATION_PERIODIC
Definition: settings.h:26

Definition at line 36 of file settings.c.

Referenced by LoadSettings().

◆ RotoStrings

const DWORD RotoStrings[]
static
Initial value:
= {
}
#define IDS_ROTATION_PERIODIC
Definition: resource.h:4
#define IDS_ROTATION_NONE
Definition: resource.h:2
#define IDS_ROTATION_LINEAR
Definition: resource.h:3

Definition at line 47 of file settings.c.

Referenced by SetupControls().

◆ Settings

SSSTARS Settings