ReactOS 0.4.15-dev-7924-g5949c20
general.c
Go to the documentation of this file.
1#include "openglcfg.h"
2
3#include <winreg.h>
4#include <debug.h>
5
7static DWORD dwNumDrivers = 0;
8
9static VOID InitSettings(HWND hWndDlg)
10{
11 HKEY hKeyRenderer;
12 HKEY hKeyDrivers;
13 DWORD dwType = 0;
15 WCHAR szBuffer[MAX_KEY_LENGTH];
16 WCHAR szBultin[MAX_KEY_LENGTH];
17 WCHAR szDriver[MAX_KEY_LENGTH];
18
19 LoadString(hApplet, IDS_DEBUG_DNM, (LPTSTR)szBultin, 127);
21
22 LoadString(hApplet, IDS_DEBUG_SET, (LPTSTR)szBultin, 127);
24
25 LoadString(hApplet, IDS_DEBUG_CLEAR, (LPTSTR)szBultin, 127);
27
29
31 SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_ADDSTRING, 0, (LPARAM)szBultin);
32
34 SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_ADDSTRING, 0, (LPARAM)szBultin);
35
37 return;
38
39 if (RegQueryValueExW(hKeyRenderer, NULL, NULL, &dwType, (LPBYTE)szDriver, &dwSize) != ERROR_SUCCESS || dwSize == sizeof(WCHAR))
41
42 RegCloseKey(hKeyRenderer);
43
44 if (dwType == REG_SZ)
45 {
46 DWORD ret;
47 DWORD iKey;
48
49 if (wcsncmp(szBultin, szDriver, MAX_KEY_LENGTH) == 0)
51
53 return;
54
56
57 if (ret != ERROR_SUCCESS || dwNumDrivers == 0)
58 {
59 RegCloseKey(hKeyDrivers);
60 return;
61 }
62
64
65 if (!pOglDrivers)
66 dwNumDrivers = 0;
67
68 for (iKey = 0; iKey < dwNumDrivers; iKey++)
69 {
71 ret = RegEnumKeyEx(hKeyDrivers, iKey, szBuffer, &dwSize, NULL, NULL, NULL, NULL);
72
73 if (ret != ERROR_SUCCESS)
74 break;
75
76 /* Mind the null terminator */
77 dwSize++;
78
79 pOglDrivers[iKey] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
80
81 if (!pOglDrivers[iKey])
82 break;
83
84 SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_ADDSTRING, 0, (LPARAM)szBuffer);
85
86 StringCchCopy(pOglDrivers[iKey], dwSize, szBuffer);
87
88 if (wcsncmp(szBuffer, szDriver, MAX_KEY_LENGTH) == 0)
89 SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_SETCURSEL, iKey + 2, 0);
90 }
91
92 RegCloseKey(hKeyDrivers);
93 }
94
95 return;
96}
97
98static VOID SaveSettings(HWND hWndDlg)
99{
100 HKEY hKeyRenderer;
101 HKEY hKeyDebug;
102 INT iSel = 0;
103
105 return;
106
108 {
109 iSel = (INT)SendDlgItemMessageW(hWndDlg, IDC_DEBUG_OUTPUT, CB_GETCURSEL, 0, 0);
110
111 switch (iSel)
112 {
113 case DEBUG_SET:
114 RegSetValueExW(hKeyDebug, L"DEBUGCHANNEL", 0, REG_SZ, (PBYTE)L"+opengl,+wgl", 13 * sizeof(WCHAR));
115 break;
116
117 case DEBUG_CLEAR:
118 RegSetValueExW(hKeyDebug, L"DEBUGCHANNEL", 0, REG_SZ, (PBYTE)L"", sizeof(WCHAR));
119 break;
120 }
121 RegCloseKey(hKeyDebug);
122 }
123
124 iSel = (INT)SendDlgItemMessageW(hWndDlg, IDC_RENDERER, CB_GETCURSEL, 0, 0);
125
126 switch (iSel)
127 {
128 case CB_ERR:
129 break;
130
131 case RENDERER_DEFAULT:
132 RegSetValueExW(hKeyRenderer, L"", 0, REG_SZ, (PBYTE)L"", sizeof(WCHAR));
133 break;
134
135 case RENDERER_RSWR:
136 {
137 WCHAR szBuffer[MAX_KEY_LENGTH];
138 LoadString(hApplet, IDS_RENDERER_RSWR, (LPTSTR)szBuffer, 127);
139 RegSetValueExW(hKeyRenderer, L"", 0, REG_SZ, (PBYTE)szBuffer, (DWORD)((wcslen(szBuffer) + 1) * sizeof(WCHAR)));
140 break;
141 }
142
143 default:
144 {
145 /* Adjustment for DEFAULT and RSWR renderers */
146 iSel -= 2;
147
148 if (iSel >= 0 && iSel < dwNumDrivers)
149 RegSetValueExW(hKeyRenderer, L"", 0, REG_SZ, (PBYTE)pOglDrivers[iSel], (DWORD)((wcslen(pOglDrivers[iSel]) + 1) * sizeof(WCHAR)));
150
151 break;
152 }
153 }
154
155 RegCloseKey(hKeyRenderer);
156}
157
158
160{
161 LPPSHNOTIFY lppsn;
162
163 switch (uMsg)
164 {
165 case WM_INITDIALOG:
166 InitSettings(hWndDlg);
167 return TRUE;
168
169 case WM_COMMAND:
170 if (LOWORD(wParam) == IDC_RENDERER ||
172 {
174 {
175 PropSheet_Changed(GetParent(hWndDlg), hWndDlg);
176 }
177 }
178 break;
179
180 case WM_NOTIFY:
181 lppsn = (LPPSHNOTIFY)lParam;
182 if (lppsn->hdr.code == PSN_APPLY)
183 {
184 SaveSettings(hWndDlg);
185 return TRUE;
186 }
187 break;
188
189 case WM_DESTROY:
190 if (pOglDrivers != NULL)
191 {
192 DWORD iKey;
193
194 for (iKey = 0; iKey < dwNumDrivers; ++iKey)
196
198 }
199 }
200
201 return FALSE;
202}
void SaveSettings(void)
Definition: settings.c:115
#define RegCloseKey(hKey)
Definition: registry.h:49
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HINSTANCE hApplet
Definition: access.c:17
INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: general.c:174
static VOID InitSettings(HWND hWndDlg)
Definition: general.c:9
static DWORD dwNumDrivers
Definition: general.c:7
static PWCHAR * pOglDrivers
Definition: general.c:6
#define IDC_RENDERER
Definition: resource.h:10
#define IDC_DEBUG_OUTPUT
Definition: resource.h:11
#define IDS_RENDERER_RSWR
Definition: resource.h:17
#define IDS_RENDERER_DEFAULT
Definition: resource.h:16
#define IDS_DEBUG_DNM
Definition: resource.h:20
#define IDS_DEBUG_SET
Definition: resource.h:18
#define IDS_DEBUG_CLEAR
Definition: resource.h:19
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:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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:4882
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define MAX_KEY_LENGTH
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
unsigned int UINT
Definition: ndis.h:50
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define L(x)
Definition: ntvdm.h:50
#define KEY_DEBUG_CHANNEL
Definition: openglcfg.h:24
#define RENDERER_RSWR
Definition: openglcfg.h:17
#define KEY_RENDERER
Definition: openglcfg.h:22
#define DEBUG_CLEAR
Definition: openglcfg.h:20
#define RENDERER_DEFAULT
Definition: openglcfg.h:16
#define DEBUG_SET
Definition: openglcfg.h:19
#define KEY_DRIVERS
Definition: openglcfg.h:23
#define LOWORD(l)
Definition: pedump.c:82
BYTE * PBYTE
Definition: pedump.c:66
#define INT
Definition: polytest.cpp:20
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
struct _PSHNOTIFY * LPPSHNOTIFY
#define WM_NOTIFY
Definition: richedit.h:61
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define StringCchCopy
Definition: strsafe.h:139
NMHDR hdr
Definition: prsht.h:330
UINT code
Definition: winuser.h:3159
int32_t INT_PTR
Definition: typedefs.h:64
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
uint16_t * PWCHAR
Definition: typedefs.h:56
#define HIWORD(l)
Definition: typedefs.h:247
int ret
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegEnumKeyEx
Definition: winreg.h:510
#define WM_COMMAND
Definition: winuser.h:1740
#define CB_ERR
Definition: winuser.h:2435
#define CB_SETCURSEL
Definition: winuser.h:1961
#define WM_INITDIALOG
Definition: winuser.h:1739
#define CBN_SELCHANGE
Definition: winuser.h:1979
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_ADDSTRING
Definition: winuser.h:1936
HWND WINAPI GetParent(_In_ HWND)
#define LoadString
Definition: winuser.h:5819
#define WM_DESTROY
Definition: winuser.h:1609
#define CB_GETCURSEL
Definition: winuser.h:1943
__wchar_t WCHAR
Definition: xmlstorage.h:180
CHAR * LPTSTR
Definition: xmlstorage.h:192