ReactOS  0.4.14-dev-342-gdc047f9
general.c
Go to the documentation of this file.
1 #include "wined3dcfg.h"
2 
3 #include <winreg.h>
4 
6 {
8  {L"1.4", REG_DWORD, 1},
9  {L"2", REG_DWORD, 2},
10  {L"3", REG_DWORD, 3},
11 };
12 
14 {
15  {VALUE_DEFAULT, REG_NONE, 0},
17 };
18 
20 {
21  {VALUE_DEFAULT, REG_NONE, 0},
22  {VALUE_ENABLED, REG_SZ, 0}
23 };
24 
26 {
27  {VALUE_DEFAULT, REG_NONE, 0},
29  {VALUE_FBO, REG_SZ, 0}
30 };
31 
33 {
34  {VALUE_DEFAULT, REG_NONE, 0},
35  {L"8 MB", REG_SZ, 8},
36  {L"16 MB", REG_SZ, 16},
37  {L"32 MB", REG_SZ, 32},
38  {L"64 MB", REG_SZ, 64},
39  {L"128 MB", REG_SZ, 128},
40  {L"256 MB", REG_SZ, 256},
41  {L"512 MB", REG_SZ, 512},
42 };
43 
45 {
46  {VALUE_DEFAULT, REG_NONE, 0},
47  {VALUE_GDI, REG_SZ, 0}
48 };
49 
50 
51 void InitControl(HWND hWndDlg, HKEY hKey, PWCHAR szKey, PWINED3D_SETTINGS pSettings, INT iControlId, INT iCount)
52 {
53  WCHAR szBuffer[MAX_KEY_LENGTH];
54  DWORD dwSize = sizeof(szBuffer);
55  DWORD dwType = 0;
56  INT iCurrent;
57  INT iActive = 0;
58 
59  RegQueryValueExW(hKey, szKey, NULL, &dwType, (LPBYTE)szBuffer, &dwSize);
60 
61  for(iCurrent = 0; iCurrent < iCount; iCurrent++)
62  {
63  SendDlgItemMessageW(hWndDlg, iControlId, CB_ADDSTRING, 0, (LPARAM)pSettings[iCurrent].szValue);
64 
65  if(dwSize && ((dwType == REG_DWORD && *szBuffer == pSettings[iCurrent].iValue) ||
66  (dwType == REG_SZ && !wcscmp(szBuffer, pSettings[iCurrent].szValue))))
67  {
68  iActive = iCurrent;
69  }
70  }
71 
72  SendDlgItemMessageW(hWndDlg, iControlId, CB_SETCURSEL, iActive, 0);
73 
74 }
75 
76 static VOID InitSettings(HWND hWndDlg)
77 {
78  HKEY hKey;
79 
81  return;
82 
84  INIT_CONTROL(OFFSCREEN, gwd3dsOffscreen);
85  INIT_CONTROL(VIDMEMSIZE, gwd3dsVidMem);
86  INIT_CONTROL(MULTISAMPLING, gwd3dsDisable);
87  INIT_CONTROL(STRICTDRAWORDERING, gwd3dsEnable);
88  INIT_CONTROL(ALWAYSOFFSCREEN, gwd3dsEnable);
89  INIT_CONTROL(DDRENDERER, gwd3dsDdRender);
90  INIT_CONTROL(PSLEVEL, gwd3dsShaderLvl);
91  INIT_CONTROL(VSLEVEL, gwd3dsShaderLvl);
92  INIT_CONTROL(GSLEVEL, gwd3dsShaderLvl);
93 
94  RegCloseKey(hKey);
95 }
96 
97 
98 static VOID SaveSetting(HWND hWnd, HKEY hKey, PWCHAR szKey, PWINED3D_SETTINGS pCfg, INT iControlId, INT iCount)
99 {
100  INT iSel = 0;
101 
102  iSel = (INT)SendDlgItemMessageW(hWnd, iControlId, CB_GETCURSEL, 0, 0);
103 
104  if(iSel < 0 || iSel > iCount)
105  return;
106 
107  if(pCfg[iSel].iType == REG_NONE)
108  {
109  RegDeleteValueW(hKey, szKey);
110  return;
111  }
112 
113  if(pCfg[iSel].iType == REG_DWORD)
114  {
115  RegSetValueExW(hKey, szKey, 0, REG_DWORD, (LPBYTE)&pCfg[iSel].iValue, sizeof(pCfg[iSel].iValue));
116  return;
117  } else if (pCfg[iSel].iType == REG_SZ)
118  {
119  RegSetValueExW(hKey, szKey, 0, pCfg[iSel].iType, (LPBYTE)pCfg[iSel].szValue, (wcslen(pCfg[iSel].szValue) + 1) * sizeof(WCHAR));
120  }
121 }
122 
123 
124 static VOID WriteSettings(HWND hWndDlg)
125 {
126  HKEY hKey;
127 
129  return;
130 
132  SAVE_CONTROL(OFFSCREEN, gwd3dsOffscreen);
133  SAVE_CONTROL(VIDMEMSIZE, gwd3dsVidMem);
134  SAVE_CONTROL(MULTISAMPLING, gwd3dsDisable);
135  SAVE_CONTROL(STRICTDRAWORDERING, gwd3dsEnable);
136  SAVE_CONTROL(ALWAYSOFFSCREEN, gwd3dsEnable);
137  SAVE_CONTROL(DDRENDERER, gwd3dsDdRender);
138  SAVE_CONTROL(PSLEVEL, gwd3dsShaderLvl);
139  SAVE_CONTROL(VSLEVEL, gwd3dsShaderLvl);
140  SAVE_CONTROL(GSLEVEL, gwd3dsShaderLvl);
141 
142  RegCloseKey(hKey);
143 }
144 
145 
147 {
148  LPPSHNOTIFY lppsn;
149 
150  switch (uMsg)
151  {
152  case WM_INITDIALOG:
153  InitSettings(hWndDlg);
154  return TRUE;
155 
156  case WM_COMMAND:
158  PropSheet_Changed(GetParent(hWndDlg), hWndDlg);
159  break;
160 
161  case WM_NOTIFY:
162  lppsn = (LPPSHNOTIFY)lParam;
163  if (lppsn->hdr.code == PSN_APPLY)
164  {
165  WriteSettings(hWndDlg);
166  return TRUE;
167  }
168  break;
169  }
170 
171  return FALSE;
172 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
WINED3D_SETTINGS gwd3dsDisable[]
Definition: general.c:13
#define VALUE_FBO
Definition: wined3dcfg.h:20
#define TRUE
Definition: types.h:120
static VOID InitSettings(HWND hWndDlg)
Definition: general.c:76
#define VALUE_BACKBUFFER
Definition: wined3dcfg.h:19
#define VALUE_DISABLED
Definition: wined3dcfg.h:17
#define ERROR_SUCCESS
Definition: deptool.c:10
struct _PSHNOTIFY * LPPSHNOTIFY
_In_ ULONG iType
Definition: winddi.h:3748
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define INT
Definition: polytest.cpp:20
#define CALLBACK
Definition: compat.h:27
HWND hWnd
Definition: settings.c:17
#define SAVE_CONTROL(a, b)
Definition: wined3dcfg.h:37
UINT_PTR WPARAM
Definition: windef.h:207
uint16_t * PWCHAR
Definition: typedefs.h:54
#define PSN_APPLY
Definition: prsht.h:117
int32_t INT_PTR
Definition: typedefs.h:62
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1925
#define KEY_WINE
Definition: wined3dcfg.h:23
WPARAM wParam
Definition: combotst.c:138
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
UINT code
Definition: winuser.h:3133
#define MAX_KEY_LENGTH
NMHDR hdr
Definition: prsht.h:312
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define IDC_MAX
Definition: resource.h:21
#define CB_ADDSTRING
Definition: winuser.h:1918
smooth NULL
Definition: ftsmooth.c:416
#define VALUE_GDI
Definition: wined3dcfg.h:15
LONG_PTR LPARAM
Definition: windef.h:208
INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: general.c:173
WINED3D_SETTINGS gwd3dsVidMem[]
Definition: general.c:32
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
void InitControl(HWND hWndDlg, HKEY hKey, PWCHAR szKey, PWINED3D_SETTINGS pSettings, INT iControlId, INT iCount)
Definition: general.c:51
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
WINED3D_SETTINGS gwd3dsEnable[]
Definition: general.c:19
#define VALUE_DEFAULT
Definition: wined3dcfg.h:21
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INIT_CONTROL(a, b)
Definition: wined3dcfg.h:36
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
#define CB_SETCURSEL
Definition: winuser.h:1943
WINED3D_SETTINGS gwd3dsDdRender[]
Definition: general.c:44
#define WM_COMMAND
Definition: winuser.h:1722
#define VALUE_ENABLED
Definition: wined3dcfg.h:16
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
HWND WINAPI GetParent(_In_ HWND)
static VOID SaveSetting(HWND hWnd, HKEY hKey, PWCHAR szKey, PWINED3D_SETTINGS pCfg, INT iControlId, INT iCount)
Definition: general.c:98
#define IDC_MIN
Definition: resource.h:10
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
WINED3D_SETTINGS gwd3dsOffscreen[]
Definition: general.c:25
static VOID WriteSettings(HWND hWndDlg)
Definition: general.c:124
unsigned int UINT
Definition: ndis.h:50
#define CBN_SELCHANGE
Definition: winuser.h:1961
#define HIWORD(l)
Definition: typedefs.h:246
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define REG_NONE
Definition: nt_native.h:1492
#define REG_DWORD
Definition: sdbapi.c:596
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define WM_NOTIFY
Definition: richedit.h:61
WINED3D_SETTINGS gwd3dsShaderLvl[]
Definition: general.c:5
#define REG_SZ
Definition: layer.c:22