[uxtheme]
[reactos.git] / reactos / dll / win32 / uxtheme / system.c
1 /*
2 * Win32 5.1 Theme system
3 *
4 * Copyright (C) 2003 Kevin Koltzau
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "uxthemep.h"
22 #include <wine/debug.h>
23
24 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
25
26 /***********************************************************************
27 * Defines and global variables
28 */
29
30 static const WCHAR szThemeManager[] = {
31 'S','o','f','t','w','a','r','e','\\',
32 'M','i','c','r','o','s','o','f','t','\\',
33 'W','i','n','d','o','w','s','\\',
34 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
35 'T','h','e','m','e','M','a','n','a','g','e','r','\0'
36 };
37 static const WCHAR szThemeActive[] = {'T','h','e','m','e','A','c','t','i','v','e','\0'};
38 static const WCHAR szSizeName[] = {'S','i','z','e','N','a','m','e','\0'};
39 static const WCHAR szColorName[] = {'C','o','l','o','r','N','a','m','e','\0'};
40 static const WCHAR szDllName[] = {'D','l','l','N','a','m','e','\0'};
41
42 static const WCHAR szIniDocumentation[] = {'d','o','c','u','m','e','n','t','a','t','i','o','n','\0'};
43
44 HINSTANCE hDllInst;
45 ATOM atDialogThemeEnabled;
46
47 static DWORD dwThemeAppProperties = STAP_ALLOW_NONCLIENT | STAP_ALLOW_CONTROLS;
48 ATOM atWindowTheme;
49 static ATOM atSubAppName;
50 static ATOM atSubIdList;
51 ATOM atWndContrext;
52
53 static BOOL bThemeActive = FALSE;
54 static WCHAR szCurrentTheme[MAX_PATH];
55 static WCHAR szCurrentColor[64];
56 static WCHAR szCurrentSize[64];
57
58 /***********************************************************************/
59
60 static BOOL CALLBACK UXTHEME_broadcast_msg_enumchild (HWND hWnd, LPARAM msg)
61 {
62 PostMessageW(hWnd, msg, 0, 0);
63 return TRUE;
64 }
65
66 /* Broadcast a message to *all* windows, including children */
67 BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg)
68 {
69 if (hWnd == NULL)
70 {
71 EnumWindows (UXTHEME_broadcast_msg, msg);
72 }
73 else
74 {
75 PostMessageW(hWnd, msg, 0, 0);
76 EnumChildWindows (hWnd, UXTHEME_broadcast_msg_enumchild, msg);
77 }
78 return TRUE;
79 }
80
81 /* At the end of the day this is a subset of what SHRegGetPath() does - copied
82 * here to avoid linking against shlwapi. */
83 static DWORD query_reg_path (HKEY hKey, LPCWSTR lpszValue,
84 LPVOID pvData)
85 {
86 DWORD dwRet, dwType, dwUnExpDataLen = MAX_PATH, dwExpDataLen;
87
88 TRACE("(hkey=%p,%s,%p)\n", hKey, debugstr_w(lpszValue),
89 pvData);
90
91 dwRet = RegQueryValueExW(hKey, lpszValue, 0, &dwType, pvData, &dwUnExpDataLen);
92 if (dwRet!=ERROR_SUCCESS && dwRet!=ERROR_MORE_DATA)
93 return dwRet;
94
95 if (dwType == REG_EXPAND_SZ)
96 {
97 DWORD nBytesToAlloc;
98
99 /* Expand type REG_EXPAND_SZ into REG_SZ */
100 LPWSTR szData;
101
102 /* If the caller didn't supply a buffer or the buffer is too small we have
103 * to allocate our own
104 */
105 if (dwRet == ERROR_MORE_DATA)
106 {
107 WCHAR cNull = '\0';
108 nBytesToAlloc = dwUnExpDataLen;
109
110 szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc);
111 RegQueryValueExW (hKey, lpszValue, 0, NULL, (LPBYTE)szData, &nBytesToAlloc);
112 dwExpDataLen = ExpandEnvironmentStringsW(szData, &cNull, 1);
113 dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
114 LocalFree(szData);
115 }
116 else
117 {
118 nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR);
119 szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc );
120 lstrcpyW(szData, pvData);
121 dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, MAX_PATH );
122 if (dwExpDataLen > MAX_PATH) dwRet = ERROR_MORE_DATA;
123 dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
124 LocalFree(szData);
125 }
126 }
127
128 return dwRet;
129 }
130
131 /***********************************************************************
132 * UXTHEME_LoadTheme
133 *
134 * Set the current active theme from the registry
135 */
136 void UXTHEME_LoadTheme(BOOL bLoad)
137 {
138 HKEY hKey;
139 DWORD buffsize;
140 HRESULT hr;
141 WCHAR tmp[10];
142 PTHEME_FILE pt;
143
144 if(bLoad == TRUE)
145 {
146 /* Get current theme configuration */
147 if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
148 TRACE("Loading theme config\n");
149 buffsize = sizeof(tmp)/sizeof(tmp[0]);
150 if(!RegQueryValueExW(hKey, szThemeActive, NULL, NULL, (LPBYTE)tmp, &buffsize)) {
151 bThemeActive = (tmp[0] != '0');
152 }
153 else {
154 bThemeActive = FALSE;
155 TRACE("Failed to get ThemeActive: %d\n", GetLastError());
156 }
157 buffsize = sizeof(szCurrentColor)/sizeof(szCurrentColor[0]);
158 if(RegQueryValueExW(hKey, szColorName, NULL, NULL, (LPBYTE)szCurrentColor, &buffsize))
159 szCurrentColor[0] = '\0';
160 buffsize = sizeof(szCurrentSize)/sizeof(szCurrentSize[0]);
161 if(RegQueryValueExW(hKey, szSizeName, NULL, NULL, (LPBYTE)szCurrentSize, &buffsize))
162 szCurrentSize[0] = '\0';
163 if (query_reg_path (hKey, szDllName, szCurrentTheme))
164 szCurrentTheme[0] = '\0';
165 RegCloseKey(hKey);
166 }
167 else
168 TRACE("Failed to open theme registry key\n");
169 }
170 else
171 {
172 bThemeActive = FALSE;
173 }
174
175 if(bThemeActive) {
176 /* Make sure the theme requested is actually valid */
177 hr = MSSTYLES_OpenThemeFile(szCurrentTheme,
178 szCurrentColor[0]?szCurrentColor:NULL,
179 szCurrentSize[0]?szCurrentSize:NULL,
180 &pt);
181 if(FAILED(hr)) {
182 bThemeActive = FALSE;
183 szCurrentTheme[0] = '\0';
184 szCurrentColor[0] = '\0';
185 szCurrentSize[0] = '\0';
186 }
187 else {
188 /* Make sure the global color & size match the theme */
189 lstrcpynW(szCurrentColor, pt->pszSelectedColor, sizeof(szCurrentColor)/sizeof(szCurrentColor[0]));
190 lstrcpynW(szCurrentSize, pt->pszSelectedSize, sizeof(szCurrentSize)/sizeof(szCurrentSize[0]));
191
192 MSSTYLES_SetActiveTheme(pt, FALSE);
193 TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme),
194 debugstr_w(szCurrentColor), debugstr_w(szCurrentSize));
195 MSSTYLES_CloseThemeFile(pt);
196 }
197 }
198 if(!bThemeActive) {
199 MSSTYLES_SetActiveTheme(NULL, FALSE);
200 TRACE("Theming not active\n");
201 }
202 }
203
204 /***********************************************************************/
205
206 static const char * const SysColorsNames[] =
207 {
208 "Scrollbar", /* COLOR_SCROLLBAR */
209 "Background", /* COLOR_BACKGROUND */
210 "ActiveTitle", /* COLOR_ACTIVECAPTION */
211 "InactiveTitle", /* COLOR_INACTIVECAPTION */
212 "Menu", /* COLOR_MENU */
213 "Window", /* COLOR_WINDOW */
214 "WindowFrame", /* COLOR_WINDOWFRAME */
215 "MenuText", /* COLOR_MENUTEXT */
216 "WindowText", /* COLOR_WINDOWTEXT */
217 "TitleText", /* COLOR_CAPTIONTEXT */
218 "ActiveBorder", /* COLOR_ACTIVEBORDER */
219 "InactiveBorder", /* COLOR_INACTIVEBORDER */
220 "AppWorkSpace", /* COLOR_APPWORKSPACE */
221 "Hilight", /* COLOR_HIGHLIGHT */
222 "HilightText", /* COLOR_HIGHLIGHTTEXT */
223 "ButtonFace", /* COLOR_BTNFACE */
224 "ButtonShadow", /* COLOR_BTNSHADOW */
225 "GrayText", /* COLOR_GRAYTEXT */
226 "ButtonText", /* COLOR_BTNTEXT */
227 "InactiveTitleText", /* COLOR_INACTIVECAPTIONTEXT */
228 "ButtonHilight", /* COLOR_BTNHIGHLIGHT */
229 "ButtonDkShadow", /* COLOR_3DDKSHADOW */
230 "ButtonLight", /* COLOR_3DLIGHT */
231 "InfoText", /* COLOR_INFOTEXT */
232 "InfoWindow", /* COLOR_INFOBK */
233 "ButtonAlternateFace", /* COLOR_ALTERNATEBTNFACE */
234 "HotTrackingColor", /* COLOR_HOTLIGHT */
235 "GradientActiveTitle", /* COLOR_GRADIENTACTIVECAPTION */
236 "GradientInactiveTitle", /* COLOR_GRADIENTINACTIVECAPTION */
237 "MenuHilight", /* COLOR_MENUHILIGHT */
238 "MenuBar", /* COLOR_MENUBAR */
239 };
240 static const WCHAR strColorKey[] =
241 { 'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
242 'C','o','l','o','r','s',0 };
243 static const WCHAR keyFlatMenus[] = { 'F','l','a','t','M','e','n','u', 0};
244 static const WCHAR keyGradientCaption[] = { 'G','r','a','d','i','e','n','t',
245 'C','a','p','t','i','o','n', 0 };
246 static const WCHAR keyNonClientMetrics[] = { 'N','o','n','C','l','i','e','n','t',
247 'M','e','t','r','i','c','s',0 };
248 static const WCHAR keyIconTitleFont[] = { 'I','c','o','n','T','i','t','l','e',
249 'F','o','n','t',0 };
250
251 static const struct BackupSysParam
252 {
253 int spiGet, spiSet;
254 const WCHAR* keyName;
255 } backupSysParams[] =
256 {
257 {SPI_GETFLATMENU, SPI_SETFLATMENU, keyFlatMenus},
258 {SPI_GETGRADIENTCAPTIONS, SPI_SETGRADIENTCAPTIONS, keyGradientCaption},
259 {-1, -1, 0}
260 };
261
262 #define NUM_SYS_COLORS (COLOR_MENUBAR+1)
263
264 static void save_sys_colors (HKEY baseKey)
265 {
266 char colorStr[13];
267 HKEY hKey;
268 int i;
269
270 if (RegCreateKeyExW( baseKey, strColorKey,
271 0, 0, 0, KEY_ALL_ACCESS,
272 0, &hKey, 0 ) == ERROR_SUCCESS)
273 {
274 for (i = 0; i < NUM_SYS_COLORS; i++)
275 {
276 COLORREF col = GetSysColor (i);
277
278 sprintf (colorStr, "%d %d %d",
279 GetRValue (col), GetGValue (col), GetBValue (col));
280
281 RegSetValueExA (hKey, SysColorsNames[i], 0, REG_SZ,
282 (BYTE*)colorStr, strlen (colorStr)+1);
283 }
284 RegCloseKey (hKey);
285 }
286 }
287
288 /* Before activating a theme, query current system colors, certain settings
289 * and backup them in the registry, so they can be restored when the theme
290 * is deactivated */
291 static void UXTHEME_BackupSystemMetrics(void)
292 {
293 HKEY hKey;
294 const struct BackupSysParam* bsp = backupSysParams;
295
296 if (RegCreateKeyExW( HKEY_CURRENT_USER, szThemeManager,
297 0, 0, 0, KEY_ALL_ACCESS,
298 0, &hKey, 0) == ERROR_SUCCESS)
299 {
300 NONCLIENTMETRICSW ncm;
301 LOGFONTW iconTitleFont;
302
303 /* back up colors */
304 save_sys_colors (hKey);
305
306 /* back up "other" settings */
307 while (bsp->spiGet >= 0)
308 {
309 DWORD value;
310
311 SystemParametersInfoW (bsp->spiGet, 0, &value, 0);
312 RegSetValueExW (hKey, bsp->keyName, 0, REG_DWORD,
313 (LPBYTE)&value, sizeof (value));
314
315 bsp++;
316 }
317
318 /* back up non-client metrics */
319 memset (&ncm, 0, sizeof (ncm));
320 ncm.cbSize = sizeof (ncm);
321 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof (ncm), &ncm, 0);
322 RegSetValueExW (hKey, keyNonClientMetrics, 0, REG_BINARY, (LPBYTE)&ncm,
323 sizeof (ncm));
324 memset (&iconTitleFont, 0, sizeof (iconTitleFont));
325 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof (iconTitleFont),
326 &iconTitleFont, 0);
327 RegSetValueExW (hKey, keyIconTitleFont, 0, REG_BINARY,
328 (LPBYTE)&iconTitleFont, sizeof (iconTitleFont));
329
330 RegCloseKey (hKey);
331 }
332 }
333
334 /* Read back old settings after a theme was deactivated */
335 static void UXTHEME_RestoreSystemMetrics(void)
336 {
337 HKEY hKey;
338 const struct BackupSysParam* bsp = backupSysParams;
339
340 if (RegOpenKeyExW (HKEY_CURRENT_USER, szThemeManager,
341 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
342 {
343 HKEY colorKey;
344
345 /* read backed-up colors */
346 if (RegOpenKeyExW (hKey, strColorKey,
347 0, KEY_QUERY_VALUE, &colorKey) == ERROR_SUCCESS)
348 {
349 int i;
350 COLORREF sysCols[NUM_SYS_COLORS];
351 int sysColsIndices[NUM_SYS_COLORS];
352 int sysColCount = 0;
353
354 for (i = 0; i < NUM_SYS_COLORS; i++)
355 {
356 DWORD type;
357 char colorStr[13];
358 DWORD count = sizeof(colorStr);
359
360 if (RegQueryValueExA (colorKey, SysColorsNames[i], 0,
361 &type, (LPBYTE) colorStr, &count) == ERROR_SUCCESS)
362 {
363 int r, g, b;
364 if (sscanf (colorStr, "%d %d %d", &r, &g, &b) == 3)
365 {
366 sysColsIndices[sysColCount] = i;
367 sysCols[sysColCount] = RGB(r, g, b);
368 sysColCount++;
369 }
370 }
371 }
372 RegCloseKey (colorKey);
373
374 SetSysColors (sysColCount, sysColsIndices, sysCols);
375 }
376
377 /* read backed-up other settings */
378 while (bsp->spiGet >= 0)
379 {
380 DWORD value;
381 DWORD count = sizeof(value);
382 DWORD type;
383
384 if (RegQueryValueExW (hKey, bsp->keyName, 0,
385 &type, (LPBYTE)&value, &count) == ERROR_SUCCESS)
386 {
387 SystemParametersInfoW (bsp->spiSet, 0, UlongToPtr(value), SPIF_UPDATEINIFILE);
388 }
389
390 bsp++;
391 }
392
393 /* read backed-up non-client metrics */
394 {
395 NONCLIENTMETRICSW ncm;
396 LOGFONTW iconTitleFont;
397 DWORD count = sizeof(ncm);
398 DWORD type;
399
400 if (RegQueryValueExW (hKey, keyNonClientMetrics, 0,
401 &type, (LPBYTE)&ncm, &count) == ERROR_SUCCESS)
402 {
403 SystemParametersInfoW (SPI_SETNONCLIENTMETRICS,
404 count, &ncm, SPIF_UPDATEINIFILE);
405 }
406
407 count = sizeof(iconTitleFont);
408
409 if (RegQueryValueExW (hKey, keyIconTitleFont, 0,
410 &type, (LPBYTE)&iconTitleFont, &count) == ERROR_SUCCESS)
411 {
412 SystemParametersInfoW (SPI_SETICONTITLELOGFONT,
413 count, &iconTitleFont, SPIF_UPDATEINIFILE);
414 }
415 }
416
417 RegCloseKey (hKey);
418 }
419 }
420
421 /* Make system settings persistent, so they're in effect even w/o uxtheme
422 * loaded.
423 * For efficiency reasons, only the last SystemParametersInfoW sets
424 * SPIF_SENDWININICHANGE */
425 static void UXTHEME_SaveSystemMetrics(void)
426 {
427 const struct BackupSysParam* bsp = backupSysParams;
428 NONCLIENTMETRICSW ncm;
429 LOGFONTW iconTitleFont;
430
431 save_sys_colors (HKEY_CURRENT_USER);
432
433 while (bsp->spiGet >= 0)
434 {
435 DWORD value;
436
437 SystemParametersInfoW (bsp->spiGet, 0, &value, 0);
438 SystemParametersInfoW (bsp->spiSet, 0, UlongToPtr(value), SPIF_UPDATEINIFILE);
439 bsp++;
440 }
441
442 memset (&ncm, 0, sizeof (ncm));
443 ncm.cbSize = sizeof (ncm);
444 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof (ncm), &ncm, 0);
445 SystemParametersInfoW (SPI_SETNONCLIENTMETRICS, sizeof (ncm), &ncm,
446 SPIF_UPDATEINIFILE);
447
448 memset (&iconTitleFont, 0, sizeof (iconTitleFont));
449 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof (iconTitleFont),
450 &iconTitleFont, 0);
451 SystemParametersInfoW (SPI_SETICONTITLELOGFONT, sizeof (iconTitleFont),
452 &iconTitleFont, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
453 }
454
455 /***********************************************************************
456 * UXTHEME_SetActiveTheme
457 *
458 * Change the current active theme
459 */
460 static HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
461 {
462 HKEY hKey;
463 WCHAR tmp[2];
464 HRESULT hr;
465
466 if(tf && !bThemeActive) UXTHEME_BackupSystemMetrics();
467 hr = MSSTYLES_SetActiveTheme(tf, TRUE);
468 if(FAILED(hr))
469 return hr;
470 if(tf) {
471 bThemeActive = TRUE;
472 lstrcpynW(szCurrentTheme, tf->szThemeFile, sizeof(szCurrentTheme)/sizeof(szCurrentTheme[0]));
473 lstrcpynW(szCurrentColor, tf->pszSelectedColor, sizeof(szCurrentColor)/sizeof(szCurrentColor[0]));
474 lstrcpynW(szCurrentSize, tf->pszSelectedSize, sizeof(szCurrentSize)/sizeof(szCurrentSize[0]));
475 }
476 else {
477 UXTHEME_RestoreSystemMetrics();
478 bThemeActive = FALSE;
479 szCurrentTheme[0] = '\0';
480 szCurrentColor[0] = '\0';
481 szCurrentSize[0] = '\0';
482 }
483
484 TRACE("Writing theme config to registry\n");
485 if(!RegCreateKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
486 tmp[0] = bThemeActive?'1':'0';
487 tmp[1] = '\0';
488 RegSetValueExW(hKey, szThemeActive, 0, REG_SZ, (const BYTE*)tmp, sizeof(WCHAR)*2);
489 if(bThemeActive) {
490 RegSetValueExW(hKey, szColorName, 0, REG_SZ, (const BYTE*)szCurrentColor,
491 (lstrlenW(szCurrentColor)+1)*sizeof(WCHAR));
492 RegSetValueExW(hKey, szSizeName, 0, REG_SZ, (const BYTE*)szCurrentSize,
493 (lstrlenW(szCurrentSize)+1)*sizeof(WCHAR));
494 RegSetValueExW(hKey, szDllName, 0, REG_SZ, (const BYTE*)szCurrentTheme,
495 (lstrlenW(szCurrentTheme)+1)*sizeof(WCHAR));
496 }
497 else {
498 RegDeleteValueW(hKey, szColorName);
499 RegDeleteValueW(hKey, szSizeName);
500 RegDeleteValueW(hKey, szDllName);
501
502 }
503 RegCloseKey(hKey);
504 }
505 else
506 TRACE("Failed to open theme registry key\n");
507
508 UXTHEME_SaveSystemMetrics ();
509
510 return hr;
511 }
512
513 /***********************************************************************
514 * UXTHEME_InitSystem
515 */
516 void UXTHEME_InitSystem(HINSTANCE hInst)
517 {
518 static const WCHAR szWindowTheme[] = {
519 'u','x','_','t','h','e','m','e','\0'
520 };
521 static const WCHAR szSubAppName[] = {
522 'u','x','_','s','u','b','a','p','p','\0'
523 };
524 static const WCHAR szSubIdList[] = {
525 'u','x','_','s','u','b','i','d','l','s','t','\0'
526 };
527 static const WCHAR szDialogThemeEnabled[] = {
528 'u','x','_','d','i','a','l','o','g','t','h','e','m','e','\0'
529 };
530
531 hDllInst = hInst;
532
533 atWindowTheme = GlobalAddAtomW(szWindowTheme);
534 atSubAppName = GlobalAddAtomW(szSubAppName);
535 atSubIdList = GlobalAddAtomW(szSubIdList);
536 atDialogThemeEnabled = GlobalAddAtomW(szDialogThemeEnabled);
537 atWndContrext = GlobalAddAtomW(L"ux_WndContext");
538 }
539
540 /***********************************************************************
541 * IsAppThemed (UXTHEME.@)
542 */
543 BOOL WINAPI IsAppThemed(void)
544 {
545 return IsThemeActive();
546 }
547
548 /***********************************************************************
549 * IsThemeActive (UXTHEME.@)
550 */
551 BOOL WINAPI IsThemeActive(void)
552 {
553 TRACE("\n");
554 SetLastError(ERROR_SUCCESS);
555 return bThemeActive;
556 }
557
558 /***********************************************************************
559 * EnableTheming (UXTHEME.@)
560 *
561 * NOTES
562 * This is a global and persistent change
563 */
564 HRESULT WINAPI EnableTheming(BOOL fEnable)
565 {
566 HKEY hKey;
567 WCHAR szEnabled[] = {'0','\0'};
568
569 TRACE("(%d)\n", fEnable);
570
571 if(fEnable != bThemeActive) {
572 if(fEnable)
573 UXTHEME_BackupSystemMetrics();
574 else
575 UXTHEME_RestoreSystemMetrics();
576 UXTHEME_SaveSystemMetrics ();
577 bThemeActive = fEnable;
578 if(bThemeActive) szEnabled[0] = '1';
579 if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
580 RegSetValueExW(hKey, szThemeActive, 0, REG_SZ, (LPBYTE)szEnabled, sizeof(WCHAR));
581 RegCloseKey(hKey);
582 }
583 UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
584 }
585 return S_OK;
586 }
587
588 /***********************************************************************
589 * UXTHEME_SetWindowProperty
590 *
591 * I'm using atoms as there may be large numbers of duplicated strings
592 * and they do the work of keeping memory down as a cause of that quite nicely
593 */
594 static HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue)
595 {
596 ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
597 if(oldValue)
598 DeleteAtom(oldValue);
599 if(pszValue) {
600 ATOM atValue = AddAtomW(pszValue);
601 if(!atValue
602 || !SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp), (LPWSTR)MAKEINTATOM(atValue))) {
603 HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
604 if(atValue) DeleteAtom(atValue);
605 return hr;
606 }
607 }
608 return S_OK;
609 }
610
611 static LPWSTR UXTHEME_GetWindowProperty(HWND hwnd, ATOM aProp, LPWSTR pszBuffer, int dwLen)
612 {
613 ATOM atValue = (ATOM)(size_t)GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
614 if(atValue) {
615 if(GetAtomNameW(atValue, pszBuffer, dwLen))
616 return pszBuffer;
617 TRACE("property defined, but unable to get value\n");
618 }
619 return NULL;
620 }
621
622 /***********************************************************************
623 * OpenThemeDataEx (UXTHEME.61)
624 */
625 HTHEME WINAPI OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD flags)
626 {
627 WCHAR szAppBuff[256];
628 WCHAR szClassBuff[256];
629 LPCWSTR pszAppName;
630 LPCWSTR pszUseClassList;
631 HTHEME hTheme = NULL;
632 TRACE("(%p,%s)\n", hwnd, debugstr_w(pszClassList));
633
634 if(!pszClassList)
635 {
636 SetLastError(E_POINTER);
637 return NULL;
638 }
639
640 if(flags)
641 FIXME("unhandled flags: %x\n", flags);
642
643 if(bThemeActive)
644 {
645 pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, sizeof(szAppBuff)/sizeof(szAppBuff[0]));
646 /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */
647 pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, sizeof(szClassBuff)/sizeof(szClassBuff[0]));
648 if(!pszUseClassList)
649 pszUseClassList = pszClassList;
650
651 if (pszUseClassList)
652 hTheme = MSSTYLES_OpenThemeClass(pszAppName, pszUseClassList);
653 }
654 if(IsWindow(hwnd))
655 SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme), hTheme);
656 TRACE(" = %p\n", hTheme);
657 return hTheme;
658 }
659
660 HTHEME WINAPI OpenThemeDataFromFile(HTHEMEFILE hThemeFile, HWND hwnd, LPCWSTR pszClassList, DWORD flags)
661 {
662 return S_OK;
663 }
664
665 /***********************************************************************
666 * OpenThemeData (UXTHEME.@)
667 */
668 HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
669 {
670 return OpenThemeDataEx(hwnd, classlist, 0);
671 }
672
673 /***********************************************************************
674 * GetWindowTheme (UXTHEME.@)
675 *
676 * Retrieve the last theme opened for a window.
677 *
678 * PARAMS
679 * hwnd [I] window to retrieve the theme for
680 *
681 * RETURNS
682 * The most recent theme.
683 */
684 HTHEME WINAPI GetWindowTheme(HWND hwnd)
685 {
686 TRACE("(%p)\n", hwnd);
687 if(!IsWindow(hwnd))
688 SetLastError(E_HANDLE);
689
690 return GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme));
691 }
692
693 /***********************************************************************
694 * SetWindowTheme (UXTHEME.@)
695 *
696 * Persistent through the life of the window, even after themes change
697 */
698 HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
699 LPCWSTR pszSubIdList)
700 {
701 HRESULT hr;
702 TRACE("(%p,%s,%s)\n", hwnd, debugstr_w(pszSubAppName),
703 debugstr_w(pszSubIdList));
704
705 if(!IsWindow(hwnd))
706 return E_HANDLE;
707
708 hr = UXTHEME_SetWindowProperty(hwnd, atSubAppName, pszSubAppName);
709 if(SUCCEEDED(hr))
710 hr = UXTHEME_SetWindowProperty(hwnd, atSubIdList, pszSubIdList);
711 if(SUCCEEDED(hr))
712 UXTHEME_broadcast_msg (hwnd, WM_THEMECHANGED);
713 return hr;
714 }
715
716 /***********************************************************************
717 * GetCurrentThemeName (UXTHEME.@)
718 */
719 HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars,
720 LPWSTR pszColorBuff, int cchMaxColorChars,
721 LPWSTR pszSizeBuff, int cchMaxSizeChars)
722 {
723 if(!bThemeActive)
724 return E_PROP_ID_UNSUPPORTED;
725 if(pszThemeFileName) lstrcpynW(pszThemeFileName, szCurrentTheme, dwMaxNameChars);
726 if(pszColorBuff) lstrcpynW(pszColorBuff, szCurrentColor, cchMaxColorChars);
727 if(pszSizeBuff) lstrcpynW(pszSizeBuff, szCurrentSize, cchMaxSizeChars);
728 return S_OK;
729 }
730
731 /***********************************************************************
732 * GetThemeAppProperties (UXTHEME.@)
733 */
734 DWORD WINAPI GetThemeAppProperties(void)
735 {
736 return dwThemeAppProperties;
737 }
738
739 /***********************************************************************
740 * SetThemeAppProperties (UXTHEME.@)
741 */
742 void WINAPI SetThemeAppProperties(DWORD dwFlags)
743 {
744 TRACE("(0x%08x)\n", dwFlags);
745 dwThemeAppProperties = dwFlags;
746 }
747
748 /***********************************************************************
749 * CloseThemeData (UXTHEME.@)
750 */
751 HRESULT WINAPI CloseThemeData(HTHEME hTheme)
752 {
753 TRACE("(%p)\n", hTheme);
754 if(!hTheme)
755 return E_HANDLE;
756 return MSSTYLES_CloseThemeClass(hTheme);
757 }
758
759 /***********************************************************************
760 * HitTestThemeBackground (UXTHEME.@)
761 */
762 HRESULT WINAPI HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId,
763 int iStateId, DWORD dwOptions,
764 const RECT *pRect, HRGN hrgn,
765 POINT ptTest, WORD *pwHitTestCode)
766 {
767 FIXME("%d %d 0x%08x: stub\n", iPartId, iStateId, dwOptions);
768 if(!hTheme)
769 return E_HANDLE;
770 return ERROR_CALL_NOT_IMPLEMENTED;
771 }
772
773 /***********************************************************************
774 * IsThemePartDefined (UXTHEME.@)
775 */
776 BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId)
777 {
778 TRACE("(%p,%d,%d)\n", hTheme, iPartId, iStateId);
779 if(!hTheme) {
780 SetLastError(E_HANDLE);
781 return FALSE;
782 }
783 if(MSSTYLES_FindPartState(hTheme, iPartId, iStateId, NULL))
784 return TRUE;
785 return FALSE;
786 }
787
788 /***********************************************************************
789 * GetThemeDocumentationProperty (UXTHEME.@)
790 *
791 * Try and retrieve the documentation property from string resources
792 * if that fails, get it from the [documentation] section of themes.ini
793 */
794 HRESULT WINAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName,
795 LPCWSTR pszPropertyName,
796 LPWSTR pszValueBuff,
797 int cchMaxValChars)
798 {
799 const WORD wDocToRes[] = {
800 TMT_DISPLAYNAME,5000,
801 TMT_TOOLTIP,5001,
802 TMT_COMPANY,5002,
803 TMT_AUTHOR,5003,
804 TMT_COPYRIGHT,5004,
805 TMT_URL,5005,
806 TMT_VERSION,5006,
807 TMT_DESCRIPTION,5007
808 };
809
810 PTHEME_FILE pt;
811 HRESULT hr;
812 unsigned int i;
813 int iDocId;
814 TRACE("(%s,%s,%p,%d)\n", debugstr_w(pszThemeName), debugstr_w(pszPropertyName),
815 pszValueBuff, cchMaxValChars);
816
817 hr = MSSTYLES_OpenThemeFile(pszThemeName, NULL, NULL, &pt);
818 if(FAILED(hr)) return hr;
819
820 /* Try to load from string resources */
821 hr = E_PROP_ID_UNSUPPORTED;
822 if(MSSTYLES_LookupProperty(pszPropertyName, NULL, &iDocId)) {
823 for(i=0; i<sizeof(wDocToRes)/sizeof(wDocToRes[0]); i+=2) {
824 if(wDocToRes[i] == iDocId) {
825 if(LoadStringW(pt->hTheme, wDocToRes[i+1], pszValueBuff, cchMaxValChars)) {
826 hr = S_OK;
827 break;
828 }
829 }
830 }
831 }
832 /* If loading from string resource failed, try getting it from the theme.ini */
833 if(FAILED(hr)) {
834 PUXINI_FILE uf = MSSTYLES_GetThemeIni(pt);
835 if(UXINI_FindSection(uf, szIniDocumentation)) {
836 LPCWSTR lpValue;
837 DWORD dwLen;
838 if(UXINI_FindValue(uf, pszPropertyName, &lpValue, &dwLen)) {
839 lstrcpynW(pszValueBuff, lpValue, min(dwLen+1,cchMaxValChars));
840 hr = S_OK;
841 }
842 }
843 UXINI_CloseINI(uf);
844 }
845
846 MSSTYLES_CloseThemeFile(pt);
847 return hr;
848 }
849
850 /**********************************************************************
851 * Undocumented functions
852 */
853
854 /**********************************************************************
855 * QueryThemeServices (UXTHEME.1)
856 *
857 * RETURNS
858 * some kind of status flag
859 */
860 DWORD WINAPI QueryThemeServices(void)
861 {
862 FIXME("stub\n");
863 return 3; /* This is what is returned under XP in most cases */
864 }
865
866
867 /**********************************************************************
868 * OpenThemeFile (UXTHEME.2)
869 *
870 * Opens a theme file, which can be used to change the current theme, etc
871 *
872 * PARAMS
873 * pszThemeFileName Path to a msstyles theme file
874 * pszColorName Color defined in the theme, eg. NormalColor
875 * pszSizeName Size defined in the theme, eg. NormalSize
876 * hThemeFile Handle to theme file
877 *
878 * RETURNS
879 * Success: S_OK
880 * Failure: HRESULT error-code
881 */
882 HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName,
883 LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile,
884 DWORD unknown)
885 {
886 TRACE("(%s,%s,%s,%p,%d)\n", debugstr_w(pszThemeFileName),
887 debugstr_w(pszColorName), debugstr_w(pszSizeName),
888 hThemeFile, unknown);
889 return MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, (PTHEME_FILE*)hThemeFile);
890 }
891
892 /**********************************************************************
893 * CloseThemeFile (UXTHEME.3)
894 *
895 * Releases theme file handle returned by OpenThemeFile
896 *
897 * PARAMS
898 * hThemeFile Handle to theme file
899 *
900 * RETURNS
901 * Success: S_OK
902 * Failure: HRESULT error-code
903 */
904 HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile)
905 {
906 TRACE("(%p)\n", hThemeFile);
907 MSSTYLES_CloseThemeFile(hThemeFile);
908 return S_OK;
909 }
910
911 /**********************************************************************
912 * ApplyTheme (UXTHEME.4)
913 *
914 * Set a theme file to be the currently active theme
915 *
916 * PARAMS
917 * hThemeFile Handle to theme file
918 * unknown See notes
919 * hWnd Window requesting the theme change
920 *
921 * RETURNS
922 * Success: S_OK
923 * Failure: HRESULT error-code
924 *
925 * NOTES
926 * I'm not sure what the second parameter is (the datatype is likely wrong), other then this:
927 * Under XP if I pass
928 * char b[] = "";
929 * the theme is applied with the screen redrawing really badly (flickers)
930 * char b[] = "\0"; where \0 can be one or more of any character, makes no difference
931 * the theme is applied smoothly (screen does not flicker)
932 * char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference
933 * the function fails returning invalid parameter... very strange
934 */
935 HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd)
936 {
937 HRESULT hr;
938 TRACE("(%p,%s,%p)\n", hThemeFile, unknown, hWnd);
939 hr = UXTHEME_SetActiveTheme(hThemeFile);
940 UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
941 return hr;
942 }
943
944 /**********************************************************************
945 * GetThemeDefaults (UXTHEME.7)
946 *
947 * Get the default color & size for a theme
948 *
949 * PARAMS
950 * pszThemeFileName Path to a msstyles theme file
951 * pszColorName Buffer to receive the default color name
952 * dwColorNameLen Length, in characters, of color name buffer
953 * pszSizeName Buffer to receive the default size name
954 * dwSizeNameLen Length, in characters, of size name buffer
955 *
956 * RETURNS
957 * Success: S_OK
958 * Failure: HRESULT error-code
959 */
960 HRESULT WINAPI GetThemeDefaults(LPCWSTR pszThemeFileName, LPWSTR pszColorName,
961 DWORD dwColorNameLen, LPWSTR pszSizeName,
962 DWORD dwSizeNameLen)
963 {
964 PTHEME_FILE pt;
965 HRESULT hr;
966 TRACE("(%s,%p,%d,%p,%d)\n", debugstr_w(pszThemeFileName),
967 pszColorName, dwColorNameLen,
968 pszSizeName, dwSizeNameLen);
969
970 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
971 if(FAILED(hr)) return hr;
972
973 lstrcpynW(pszColorName, pt->pszSelectedColor, dwColorNameLen);
974 lstrcpynW(pszSizeName, pt->pszSelectedSize, dwSizeNameLen);
975
976 MSSTYLES_CloseThemeFile(pt);
977 return S_OK;
978 }
979
980 /**********************************************************************
981 * EnumThemes (UXTHEME.8)
982 *
983 * Enumerate available themes, calls specified EnumThemeProc for each
984 * theme found. Passes lpData through to callback function.
985 *
986 * PARAMS
987 * pszThemePath Path containing themes
988 * callback Called for each theme found in path
989 * lpData Passed through to callback
990 *
991 * RETURNS
992 * Success: S_OK
993 * Failure: HRESULT error-code
994 */
995 HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, ENUMTHEMEPROC callback,
996 LPVOID lpData)
997 {
998 WCHAR szDir[MAX_PATH];
999 WCHAR szPath[MAX_PATH];
1000 static const WCHAR szStar[] = {'*','.','*','\0'};
1001 static const WCHAR szFormat[] = {'%','s','%','s','\\','%','s','.','m','s','s','t','y','l','e','s','\0'};
1002 static const WCHAR szDisplayName[] = {'d','i','s','p','l','a','y','n','a','m','e','\0'};
1003 static const WCHAR szTooltip[] = {'t','o','o','l','t','i','p','\0'};
1004 WCHAR szName[60];
1005 WCHAR szTip[60];
1006 HANDLE hFind;
1007 WIN32_FIND_DATAW wfd;
1008 HRESULT hr;
1009 size_t pathLen;
1010
1011 TRACE("(%s,%p,%p)\n", debugstr_w(pszThemePath), callback, lpData);
1012
1013 if(!pszThemePath || !callback)
1014 return E_POINTER;
1015
1016 lstrcpyW(szDir, pszThemePath);
1017 pathLen = lstrlenW (szDir);
1018 if ((pathLen > 0) && (pathLen < MAX_PATH-1) && (szDir[pathLen - 1] != '\\'))
1019 {
1020 szDir[pathLen] = '\\';
1021 szDir[pathLen+1] = 0;
1022 }
1023
1024 lstrcpyW(szPath, szDir);
1025 lstrcatW(szPath, szStar);
1026 TRACE("searching %s\n", debugstr_w(szPath));
1027
1028 hFind = FindFirstFileW(szPath, &wfd);
1029 if(hFind != INVALID_HANDLE_VALUE) {
1030 do {
1031 if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
1032 && !(wfd.cFileName[0] == '.' && ((wfd.cFileName[1] == '.' && wfd.cFileName[2] == 0) || wfd.cFileName[1] == 0))) {
1033 wsprintfW(szPath, szFormat, szDir, wfd.cFileName, wfd.cFileName);
1034
1035 hr = GetThemeDocumentationProperty(szPath, szDisplayName, szName, sizeof(szName)/sizeof(szName[0]));
1036 if(SUCCEEDED(hr))
1037 hr = GetThemeDocumentationProperty(szPath, szTooltip, szTip, sizeof(szTip)/sizeof(szTip[0]));
1038 if(SUCCEEDED(hr)) {
1039 TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath), debugstr_w(szName), debugstr_w(szTip), lpData);
1040 if(!callback(NULL, szPath, szName, szTip, NULL, lpData)) {
1041 TRACE("callback ended enum\n");
1042 break;
1043 }
1044 }
1045 }
1046 } while(FindNextFileW(hFind, &wfd));
1047 FindClose(hFind);
1048 }
1049 return S_OK;
1050 }
1051
1052
1053 /**********************************************************************
1054 * EnumThemeColors (UXTHEME.9)
1055 *
1056 * Enumerate theme colors available with a particular size
1057 *
1058 * PARAMS
1059 * pszThemeFileName Path to a msstyles theme file
1060 * pszSizeName Theme size to enumerate available colors
1061 * If NULL the default theme size is used
1062 * dwColorNum Color index to retrieve, increment from 0
1063 * pszColorNames Output color names
1064 *
1065 * RETURNS
1066 * S_OK on success
1067 * E_PROP_ID_UNSUPPORTED when dwColorName does not refer to a color
1068 * or when pszSizeName does not refer to a valid size
1069 *
1070 * NOTES
1071 * XP fails with E_POINTER when pszColorNames points to a buffer smaller than
1072 * sizeof(THEMENAMES).
1073 *
1074 * Not very efficient that I'm opening & validating the theme every call, but
1075 * this is undocumented and almost never called..
1076 * (and this is how windows works too)
1077 */
1078 HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName,
1079 DWORD dwColorNum, PTHEMENAMES pszColorNames)
1080 {
1081 PTHEME_FILE pt;
1082 HRESULT hr;
1083 LPWSTR tmp;
1084 UINT resourceId = dwColorNum + 1000;
1085 TRACE("(%s,%s,%d)\n", debugstr_w(pszThemeFileName),
1086 debugstr_w(pszSizeName), dwColorNum);
1087
1088 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, pszSizeName, &pt);
1089 if(FAILED(hr)) return hr;
1090
1091 tmp = pt->pszAvailColors;
1092 while(dwColorNum && *tmp) {
1093 dwColorNum--;
1094 tmp += lstrlenW(tmp)+1;
1095 }
1096 if(!dwColorNum && *tmp) {
1097 TRACE("%s\n", debugstr_w(tmp));
1098 lstrcpyW(pszColorNames->szName, tmp);
1099 LoadStringW (pt->hTheme, resourceId,
1100 pszColorNames->szDisplayName,
1101 sizeof (pszColorNames->szDisplayName) / sizeof (WCHAR));
1102 LoadStringW (pt->hTheme, resourceId+1000,
1103 pszColorNames->szTooltip,
1104 sizeof (pszColorNames->szTooltip) / sizeof (WCHAR));
1105 }
1106 else
1107 hr = E_PROP_ID_UNSUPPORTED;
1108
1109 MSSTYLES_CloseThemeFile(pt);
1110 return hr;
1111 }
1112
1113 /**********************************************************************
1114 * EnumThemeSizes (UXTHEME.10)
1115 *
1116 * Enumerate theme colors available with a particular size
1117 *
1118 * PARAMS
1119 * pszThemeFileName Path to a msstyles theme file
1120 * pszColorName Theme color to enumerate available sizes
1121 * If NULL the default theme color is used
1122 * dwSizeNum Size index to retrieve, increment from 0
1123 * pszSizeNames Output size names
1124 *
1125 * RETURNS
1126 * S_OK on success
1127 * E_PROP_ID_UNSUPPORTED when dwSizeName does not refer to a size
1128 * or when pszColorName does not refer to a valid color
1129 *
1130 * NOTES
1131 * XP fails with E_POINTER when pszSizeNames points to a buffer smaller than
1132 * sizeof(THEMENAMES).
1133 *
1134 * Not very efficient that I'm opening & validating the theme every call, but
1135 * this is undocumented and almost never called..
1136 * (and this is how windows works too)
1137 */
1138 HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName,
1139 DWORD dwSizeNum, PTHEMENAMES pszSizeNames)
1140 {
1141 PTHEME_FILE pt;
1142 HRESULT hr;
1143 LPWSTR tmp;
1144 UINT resourceId = dwSizeNum + 3000;
1145 TRACE("(%s,%s,%d)\n", debugstr_w(pszThemeFileName),
1146 debugstr_w(pszColorName), dwSizeNum);
1147
1148 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, NULL, &pt);
1149 if(FAILED(hr)) return hr;
1150
1151 tmp = pt->pszAvailSizes;
1152 while(dwSizeNum && *tmp) {
1153 dwSizeNum--;
1154 tmp += lstrlenW(tmp)+1;
1155 }
1156 if(!dwSizeNum && *tmp) {
1157 TRACE("%s\n", debugstr_w(tmp));
1158 lstrcpyW(pszSizeNames->szName, tmp);
1159 LoadStringW (pt->hTheme, resourceId,
1160 pszSizeNames->szDisplayName,
1161 sizeof (pszSizeNames->szDisplayName) / sizeof (WCHAR));
1162 LoadStringW (pt->hTheme, resourceId+1000,
1163 pszSizeNames->szTooltip,
1164 sizeof (pszSizeNames->szTooltip) / sizeof (WCHAR));
1165 }
1166 else
1167 hr = E_PROP_ID_UNSUPPORTED;
1168
1169 MSSTYLES_CloseThemeFile(pt);
1170 return hr;
1171 }
1172
1173 /**********************************************************************
1174 * ParseThemeIniFile (UXTHEME.11)
1175 *
1176 * Enumerate data in a theme INI file.
1177 *
1178 * PARAMS
1179 * pszIniFileName Path to a theme ini file
1180 * pszUnknown Cannot be NULL, L"" is valid
1181 * callback Called for each found entry
1182 * lpData Passed through to callback
1183 *
1184 * RETURNS
1185 * S_OK on success
1186 * 0x800706488 (Unknown property) when enumeration is canceled from callback
1187 *
1188 * NOTES
1189 * When pszUnknown is NULL the callback is never called, the value does not seem to serve
1190 * any other purpose
1191 */
1192 HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
1193 PARSETHEMEINIFILEPROC callback, LPVOID lpData)
1194 {
1195 FIXME("%s %s: stub\n", debugstr_w(pszIniFileName), debugstr_w(pszUnknown));
1196 return ERROR_CALL_NOT_IMPLEMENTED;
1197 }
1198
1199 /**********************************************************************
1200 * CheckThemeSignature (UXTHEME.29)
1201 *
1202 * Validates the signature of a theme file
1203 *
1204 * PARAMS
1205 * pszIniFileName Path to a theme file
1206 *
1207 * RETURNS
1208 * Success: S_OK
1209 * Failure: HRESULT error-code
1210 */
1211 HRESULT WINAPI CheckThemeSignature(LPCWSTR pszThemeFileName)
1212 {
1213 PTHEME_FILE pt;
1214 HRESULT hr;
1215 TRACE("(%s)\n", debugstr_w(pszThemeFileName));
1216 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
1217 if(FAILED(hr))
1218 return hr;
1219 MSSTYLES_CloseThemeFile(pt);
1220 return S_OK;
1221 }
1222
1223 HRESULT WINAPI DrawNCPreview(HDC hDC,
1224 DWORD DNCP_Flag,
1225 LPRECT prcPreview,
1226 LPCWSTR pszThemeFileName,
1227 LPCWSTR pszColorName,
1228 LPCWSTR pszSizeName,
1229 PNONCLIENTMETRICSW pncMetrics,
1230 COLORREF* lpaRgbValues)
1231 {
1232 return S_OK;
1233 }
1234