settings.c File Reference

#include "winefile.h"

Include dependency graph for settings.c:

Go to the source code of this file.

Functions

void save_registry_settings (void)
void load_registry_settings (struct WINDOW_OPTIONS *pOpts)

Variables

static const WCHAR registry_key []
static const WCHAR reg_start_x [] = { 's','t','a','r','t','X','\0'}
static const WCHAR reg_start_y [] = { 's','t','a','r','t','Y','\0'}
static const WCHAR reg_width [] = { 'w','i','d','t','h','\0'}
static const WCHAR reg_height [] = { 'h','e','i','g','h','t','\0'}
static const WCHAR reg_logfont [] = { 'l','o','g','f','o','n','t','\0'}


Function Documentation

void load_registry_settings ( struct WINDOW_OPTIONS pOpts  ) 

Definition at line 82 of file settings.c.

References Globals, WINDOW_OPTIONS::height, WINEFILE_GLOBALS::hfont, reg_height, reg_logfont, reg_start_x, reg_start_y, reg_width, registry_key, WINDOW_OPTIONS::start_x, WINDOW_OPTIONS::start_y, and WINDOW_OPTIONS::width.

00083 {
00084     DWORD size;
00085     DWORD type;
00086     HKEY hKey;
00087     LOGFONT logfont;
00088 
00089     RegOpenKeyExW(HKEY_CURRENT_USER, registry_key, 0, KEY_QUERY_VALUE, &hKey);
00090 
00091     size = sizeof(DWORD);
00092 
00093     if (RegQueryValueExW(hKey, reg_start_x, NULL, &type,
00094                   (LPBYTE) &pOpts->start_x, &size) != ERROR_SUCCESS)
00095         pOpts->start_x = CW_USEDEFAULT;
00096 
00097     if (RegQueryValueExW(hKey, reg_start_y, NULL, &type,
00098                   (LPBYTE) &pOpts->start_y, &size) != ERROR_SUCCESS)
00099         pOpts->start_y = CW_USEDEFAULT;
00100 
00101     if (RegQueryValueExW(hKey, reg_width, NULL, &type,
00102                   (LPBYTE) &pOpts->width, &size) != ERROR_SUCCESS)
00103         pOpts->width = CW_USEDEFAULT;
00104 
00105     if (RegQueryValueExW(hKey, reg_height, NULL, &type,
00106                   (LPBYTE) &pOpts->height, &size) != ERROR_SUCCESS)
00107         pOpts->height = CW_USEDEFAULT;
00108 
00109     size = sizeof(logfont);
00110 
00111     if (RegQueryValueExW(hKey, reg_logfont, NULL, &type,
00112                   (LPBYTE) &logfont, &size) != ERROR_SUCCESS)
00113         GetObject(GetStockObject(DEFAULT_GUI_FONT),sizeof(logfont),&logfont);
00114 
00115     RegCloseKey(hKey);
00116 
00117     Globals.hfont = CreateFontIndirect(&logfont);
00118 }

void save_registry_settings ( void   ) 

Definition at line 37 of file settings.c.

References Globals, WINEFILE_GLOBALS::hfont, WINEFILE_GLOBALS::hMainWnd, reg_height, reg_logfont, reg_start_x, reg_start_y, reg_width, and registry_key.

Referenced by FrameWndProc().

00038 {
00039     WINDOWINFO wi;
00040     HKEY hKey;
00041     INT width, height;
00042     LOGFONT logfont;
00043 
00044     wi.cbSize = sizeof(WINDOWINFO);
00045     GetWindowInfo(Globals.hMainWnd, &wi);
00046     width = wi.rcWindow.right - wi.rcWindow.left;
00047     height = wi.rcWindow.bottom - wi.rcWindow.top;
00048 
00049     if (RegOpenKeyExW(HKEY_CURRENT_USER, registry_key,
00050                 0, KEY_SET_VALUE, &hKey) != ERROR_SUCCESS)
00051     {
00052         /* Unable to save registry settings - try to create key */
00053         if (RegCreateKeyExW(HKEY_CURRENT_USER, registry_key,
00054                       0, NULL, REG_OPTION_NON_VOLATILE,
00055                       KEY_SET_VALUE, NULL, &hKey, NULL) != ERROR_SUCCESS)
00056         {
00057             /* FIXME: Cannot create key */
00058             return;
00059         }
00060     }
00061 
00062     /* Save all of the settings */
00063     RegSetValueExW(hKey, reg_start_x, 0, REG_DWORD,
00064             (LPBYTE) &wi.rcWindow.left, sizeof(DWORD));
00065     RegSetValueExW(hKey, reg_start_y, 0, REG_DWORD,
00066             (LPBYTE) &wi.rcWindow.top, sizeof(DWORD));
00067     RegSetValueExW(hKey, reg_width, 0, REG_DWORD,
00068             (LPBYTE) &width, sizeof(DWORD));
00069     RegSetValueExW(hKey, reg_height, 0, REG_DWORD,
00070             (LPBYTE) &height, sizeof(DWORD));
00071     GetObject(Globals.hfont, sizeof(logfont), &logfont);
00072     RegSetValueExW(hKey, reg_logfont, 0, REG_BINARY,
00073             (LPBYTE) &logfont, sizeof(LOGFONT));
00074 
00075     /* TODO: Save more settings here (List vs. Detailed View, etc.) */
00076     RegCloseKey(hKey);
00077 }

Here is the caller graph for this function:


Variable Documentation

const WCHAR reg_height[] = { 'h','e','i','g','h','t','\0'} [static]

Definition at line 31 of file settings.c.

Referenced by load_registry_settings(), and save_registry_settings().

const WCHAR reg_logfont[] = { 'l','o','g','f','o','n','t','\0'} [static]

Definition at line 32 of file settings.c.

Referenced by load_registry_settings(), and save_registry_settings().

const WCHAR reg_start_x[] = { 's','t','a','r','t','X','\0'} [static]

Definition at line 28 of file settings.c.

Referenced by load_registry_settings(), and save_registry_settings().

const WCHAR reg_start_y[] = { 's','t','a','r','t','Y','\0'} [static]

Definition at line 29 of file settings.c.

Referenced by load_registry_settings(), and save_registry_settings().

const WCHAR reg_width[] = { 'w','i','d','t','h','\0'} [static]

Definition at line 30 of file settings.c.

Referenced by load_registry_settings(), and save_registry_settings().

const WCHAR registry_key[] [static]

Initial value:

 { 'S','o','f','t','w','a','r','e','\\',
                                      'W','i','n','e','\\',
                                      'W','i','n','e','F','i','l','e','\0'}

Definition at line 25 of file settings.c.

Referenced by load_registry_settings(), and save_registry_settings().


Winefile Source Code Documentation
generated on 15.09.2008 by doxygen

Winefile Homepage