6 static PWCHAR
*pOglDrivers
= NULL
;
7 static DWORD dwNumDrivers
= 0;
9 static VOID
InitSettings(HWND hWndDlg
)
14 DWORD dwSize
= MAX_KEY_LENGTH
;
15 WCHAR szBuffer
[MAX_KEY_LENGTH
];
16 WCHAR szBultin
[MAX_KEY_LENGTH
];
17 WCHAR szDriver
[MAX_KEY_LENGTH
];
19 LoadString(hApplet
, IDS_DEBUG_DNM
, (LPTSTR
)szBultin
, 127);
20 SendDlgItemMessageW(hWndDlg
, IDC_DEBUG_OUTPUT
, CB_ADDSTRING
, 0, (LPARAM
)szBultin
);
22 LoadString(hApplet
, IDS_DEBUG_SET
, (LPTSTR
)szBultin
, 127);
23 SendDlgItemMessageW(hWndDlg
, IDC_DEBUG_OUTPUT
, CB_ADDSTRING
, 0, (LPARAM
)szBultin
);
25 LoadString(hApplet
, IDS_DEBUG_CLEAR
, (LPTSTR
)szBultin
, 127);
26 SendDlgItemMessageW(hWndDlg
, IDC_DEBUG_OUTPUT
, CB_ADDSTRING
, 0, (LPARAM
)szBultin
);
28 SendDlgItemMessageW(hWndDlg
, IDC_DEBUG_OUTPUT
, CB_SETCURSEL
, 0, 0);
30 LoadString(hApplet
, IDS_RENDERER_DEFAULT
, (LPTSTR
)szBultin
, 127);
31 SendDlgItemMessageW(hWndDlg
, IDC_RENDERER
, CB_ADDSTRING
, 0, (LPARAM
)szBultin
);
33 LoadString(hApplet
, IDS_RENDERER_RSWR
, (LPTSTR
)szBultin
, 127);
34 SendDlgItemMessageW(hWndDlg
, IDC_RENDERER
, CB_ADDSTRING
, 0, (LPARAM
)szBultin
);
36 if (RegCreateKeyExW(HKEY_CURRENT_USER
, KEY_RENDERER
, 0, NULL
, 0, MAXIMUM_ALLOWED
, NULL
, &hKeyRenderer
, NULL
) != ERROR_SUCCESS
)
39 if (RegQueryValueExW(hKeyRenderer
, NULL
, NULL
, &dwType
, (LPBYTE
)szDriver
, &dwSize
) != ERROR_SUCCESS
|| dwSize
== sizeof(WCHAR
))
40 SendDlgItemMessageW(hWndDlg
, IDC_RENDERER
, CB_SETCURSEL
, RENDERER_DEFAULT
, 0);
42 RegCloseKey(hKeyRenderer
);
49 if (wcsncmp(szBultin
, szDriver
, MAX_KEY_LENGTH
) == 0)
50 SendDlgItemMessageW(hWndDlg
, IDC_RENDERER
, CB_SETCURSEL
, RENDERER_RSWR
, 0);
52 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, KEY_DRIVERS
, 0, KEY_READ
, &hKeyDrivers
) != ERROR_SUCCESS
)
55 ret
= RegQueryInfoKeyW(hKeyDrivers
, NULL
, NULL
, NULL
, &dwNumDrivers
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
57 if (ret
!= ERROR_SUCCESS
|| dwNumDrivers
== 0)
59 RegCloseKey(hKeyDrivers
);
63 pOglDrivers
= HeapAlloc(GetProcessHeap(), 0, dwNumDrivers
* sizeof(PWCHAR
));
68 for (iKey
= 0; iKey
< dwNumDrivers
; iKey
++)
70 dwSize
= MAX_KEY_LENGTH
;
71 ret
= RegEnumKeyEx(hKeyDrivers
, iKey
, szBuffer
, &dwSize
, NULL
, NULL
, NULL
, NULL
);
73 if (ret
!= ERROR_SUCCESS
)
76 /* Mind the null terminator */
79 pOglDrivers
[iKey
] = HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
81 if (!pOglDrivers
[iKey
])
84 SendDlgItemMessageW(hWndDlg
, IDC_RENDERER
, CB_ADDSTRING
, 0, (LPARAM
)szBuffer
);
86 StringCchCopy(pOglDrivers
[iKey
], dwSize
, szBuffer
);
88 if (wcsncmp(szBuffer
, szDriver
, MAX_KEY_LENGTH
) == 0)
89 SendDlgItemMessageW(hWndDlg
, IDC_RENDERER
, CB_SETCURSEL
, iKey
+ 2, 0);
92 RegCloseKey(hKeyDrivers
);
98 static VOID
SaveSettings(HWND hWndDlg
)
104 if (RegOpenKeyExW(HKEY_CURRENT_USER
, KEY_RENDERER
, 0, KEY_WRITE
, &hKeyRenderer
) != ERROR_SUCCESS
)
107 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, KEY_DEBUG_CHANNEL
, 0, KEY_WRITE
, &hKeyDebug
) == ERROR_SUCCESS
)
109 iSel
= (INT
)SendDlgItemMessageW(hWndDlg
, IDC_DEBUG_OUTPUT
, CB_GETCURSEL
, 0, 0);
114 RegSetValueExW(hKeyDebug
, L
"DEBUGCHANNEL", 0, REG_SZ
, (PBYTE
)L
"+opengl,+wgl", 13 * sizeof(WCHAR
));
118 RegSetValueExW(hKeyDebug
, L
"DEBUGCHANNEL", 0, REG_SZ
, (PBYTE
)L
"", sizeof(WCHAR
));
121 RegCloseKey(hKeyDebug
);
124 iSel
= (INT
)SendDlgItemMessageW(hWndDlg
, IDC_RENDERER
, CB_GETCURSEL
, 0, 0);
131 case RENDERER_DEFAULT
:
132 RegSetValueExW(hKeyRenderer
, L
"", 0, REG_SZ
, (PBYTE
)L
"", sizeof(WCHAR
));
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
)));
145 /* Adjustment for DEFAULT and RSWR renderers */
148 if (iSel
>= 0 && iSel
< dwNumDrivers
)
149 RegSetValueExW(hKeyRenderer
, L
"", 0, REG_SZ
, (PBYTE
)pOglDrivers
[iSel
], (DWORD
)((wcslen(pOglDrivers
[iSel
]) + 1) * sizeof(WCHAR
)));
155 RegCloseKey(hKeyRenderer
);
159 INT_PTR CALLBACK
GeneralPageProc(HWND hWndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
166 InitSettings(hWndDlg
);
170 if (LOWORD(wParam
) == IDC_RENDERER
||
171 LOWORD(wParam
) == IDC_DEBUG_OUTPUT
)
173 if (HIWORD(wParam
) == CBN_SELCHANGE
)
175 PropSheet_Changed(GetParent(hWndDlg
), hWndDlg
);
181 lppsn
= (LPPSHNOTIFY
)lParam
;
182 if (lppsn
->hdr
.code
== PSN_APPLY
)
184 SaveSettings(hWndDlg
);
190 if (pOglDrivers
!= NULL
)
194 for (iKey
= 0; iKey
< dwNumDrivers
; ++iKey
)
195 HeapFree(GetProcessHeap(), 0, pOglDrivers
[iKey
]);
197 HeapFree(GetProcessHeap(), 0, pOglDrivers
);