2 * Win32 5.1 Theme system
4 * Copyright (C) 2003 Kevin Koltzau
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include "uxthemedll.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme
);
41 /***********************************************************************
42 * Defines and global variables
45 static const WCHAR szThemeManager
[] = {
46 'S','o','f','t','w','a','r','e','\\',
47 'M','i','c','r','o','s','o','f','t','\\',
48 'W','i','n','d','o','w','s','\\',
49 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
50 'T','h','e','m','e','M','a','n','a','g','e','r','\0'
52 static const WCHAR szThemeActive
[] = {'T','h','e','m','e','A','c','t','i','v','e','\0'};
53 static const WCHAR szSizeName
[] = {'S','i','z','e','N','a','m','e','\0'};
54 static const WCHAR szColorName
[] = {'C','o','l','o','r','N','a','m','e','\0'};
55 static const WCHAR szDllName
[] = {'D','l','l','N','a','m','e','\0'};
57 static const WCHAR szIniDocumentation
[] = {'d','o','c','u','m','e','n','t','a','t','i','o','n','\0'};
61 DWORD dwThemeAppProperties
= STAP_ALLOW_NONCLIENT
| STAP_ALLOW_CONTROLS
;
66 BOOL bThemeActive
= FALSE
;
67 WCHAR szCurrentTheme
[MAX_PATH
];
68 WCHAR szCurrentColor
[64];
69 WCHAR szCurrentSize
[64];
71 /***********************************************************************/
73 static BOOL CALLBACK
UXTHEME_broadcast_msg_enumchild (HWND hWnd
, LPARAM msg
)
75 PostMessageW(hWnd
, msg
, 0, 0);
79 /* Broadcast a message to *all* windows, including children */
80 static BOOL CALLBACK
UXTHEME_broadcast_msg (HWND hWnd
, LPARAM msg
)
84 EnumWindows (UXTHEME_broadcast_msg
, msg
);
88 PostMessageW(hWnd
, msg
, 0, 0);
89 EnumChildWindows (hWnd
, UXTHEME_broadcast_msg_enumchild
, msg
);
94 /***********************************************************************
97 * Set the current active theme from the registry
99 static void UXTHEME_LoadTheme(void)
107 /* Get current theme configuration */
108 if(!RegOpenKeyW(HKEY_CURRENT_USER
, szThemeManager
, &hKey
)) {
109 TRACE("Loading theme config\n");
110 buffsize
= sizeof(tmp
)/sizeof(tmp
[0]);
111 if(!RegQueryValueExW(hKey
, szThemeActive
, NULL
, NULL
, (LPBYTE
)tmp
, &buffsize
)) {
112 bThemeActive
= (tmp
[0] != '0');
115 bThemeActive
= FALSE
;
116 TRACE("Failed to get ThemeActive: %ld\n", GetLastError());
118 buffsize
= sizeof(szCurrentColor
)/sizeof(szCurrentColor
[0]);
119 if(RegQueryValueExW(hKey
, szColorName
, NULL
, NULL
, (LPBYTE
)szCurrentColor
, &buffsize
))
120 szCurrentColor
[0] = '\0';
121 buffsize
= sizeof(szCurrentSize
)/sizeof(szCurrentSize
[0]);
122 if(RegQueryValueExW(hKey
, szSizeName
, NULL
, NULL
, (LPBYTE
)szCurrentSize
, &buffsize
))
123 szCurrentSize
[0] = '\0';
124 if(SHRegGetPathW(hKey
, NULL
, szDllName
, szCurrentTheme
, 0))
125 szCurrentTheme
[0] = '\0';
129 TRACE("Failed to open theme registry key\n");
132 /* Make sure the theme requested is actually valid */
133 hr
= MSSTYLES_OpenThemeFile(szCurrentTheme
,
134 szCurrentColor
[0]?szCurrentColor
:NULL
,
135 szCurrentSize
[0]?szCurrentSize
:NULL
,
138 bThemeActive
= FALSE
;
139 szCurrentTheme
[0] = '\0';
140 szCurrentColor
[0] = '\0';
141 szCurrentSize
[0] = '\0';
144 /* Make sure the global color & size match the theme */
145 lstrcpynW(szCurrentColor
, pt
->pszSelectedColor
, sizeof(szCurrentColor
)/sizeof(szCurrentColor
[0]));
146 lstrcpynW(szCurrentSize
, pt
->pszSelectedSize
, sizeof(szCurrentSize
)/sizeof(szCurrentSize
[0]));
148 MSSTYLES_SetActiveTheme(pt
);
149 TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme
),
150 debugstr_w(szCurrentColor
), debugstr_w(szCurrentSize
));
151 MSSTYLES_CloseThemeFile(pt
);
155 MSSTYLES_SetActiveTheme(NULL
);
156 TRACE("Themeing not active\n");
160 /***********************************************************************
161 * UXTHEME_SetActiveTheme
163 * Change the current active theme
165 HRESULT
UXTHEME_SetActiveTheme(PTHEME_FILE tf
)
171 hr
= MSSTYLES_SetActiveTheme(tf
);
176 lstrcpynW(szCurrentTheme
, tf
->szThemeFile
, sizeof(szCurrentTheme
)/sizeof(szCurrentTheme
[0]));
177 lstrcpynW(szCurrentColor
, tf
->pszSelectedColor
, sizeof(szCurrentColor
)/sizeof(szCurrentColor
[0]));
178 lstrcpynW(szCurrentSize
, tf
->pszSelectedSize
, sizeof(szCurrentSize
)/sizeof(szCurrentSize
[0]));
181 bThemeActive
= FALSE
;
182 szCurrentTheme
[0] = '\0';
183 szCurrentColor
[0] = '\0';
184 szCurrentSize
[0] = '\0';
187 TRACE("Writing theme config to registry\n");
188 if(!RegCreateKeyW(HKEY_CURRENT_USER
, szThemeManager
, &hKey
)) {
189 tmp
[0] = bThemeActive
?'1':'0';
191 RegSetValueExW(hKey
, szThemeActive
, 0, REG_SZ
, (const BYTE
*)tmp
, sizeof(WCHAR
)*2);
193 RegSetValueExW(hKey
, szColorName
, 0, REG_SZ
, (const BYTE
*)szCurrentColor
,
194 (lstrlenW(szCurrentColor
)+1)*sizeof(WCHAR
));
195 RegSetValueExW(hKey
, szSizeName
, 0, REG_SZ
, (const BYTE
*)szCurrentSize
,
196 (lstrlenW(szCurrentSize
)+1)*sizeof(WCHAR
));
197 RegSetValueExW(hKey
, szDllName
, 0, REG_SZ
, (const BYTE
*)szCurrentTheme
,
198 (lstrlenW(szCurrentTheme
)+1)*sizeof(WCHAR
));
201 RegDeleteValueW(hKey
, szColorName
);
202 RegDeleteValueW(hKey
, szSizeName
);
203 RegDeleteValueW(hKey
, szDllName
);
209 TRACE("Failed to open theme registry key\n");
213 /***********************************************************************
216 void UXTHEME_InitSystem(HINSTANCE hInst
)
218 static const WCHAR szWindowTheme
[] = {
219 'u','x','_','t','h','e','m','e','\0'
221 static const WCHAR szSubAppName
[] = {
222 'u','x','_','s','u','b','a','p','p','\0'
224 static const WCHAR szSubIdList
[] = {
225 'u','x','_','s','u','b','i','d','l','s','t','\0'
230 atWindowTheme
= GlobalAddAtomW(szWindowTheme
);
231 atSubAppName
= GlobalAddAtomW(szSubAppName
);
232 atSubIdList
= GlobalAddAtomW(szSubIdList
);
237 /***********************************************************************
238 * IsAppThemed (UXTHEME.@)
240 BOOL WINAPI
IsAppThemed(void)
242 return IsThemeActive();
245 /***********************************************************************
246 * IsThemeActive (UXTHEME.@)
248 BOOL WINAPI
IsThemeActive(void)
254 /***********************************************************************
255 * EnableTheming (UXTHEME.@)
258 * This is a global and persistent change
260 HRESULT WINAPI
EnableTheming(BOOL fEnable
)
263 WCHAR szEnabled
[] = {'0','\0'};
265 TRACE("(%d)\n", fEnable
);
267 if(fEnable
!= bThemeActive
) {
268 bThemeActive
= fEnable
;
269 if(bThemeActive
) szEnabled
[0] = '1';
270 if(!RegOpenKeyW(HKEY_CURRENT_USER
, szThemeManager
, &hKey
)) {
271 RegSetValueExW(hKey
, szThemeActive
, 0, REG_SZ
, (LPBYTE
)szEnabled
, sizeof(WCHAR
));
274 UXTHEME_broadcast_msg (NULL
, WM_THEMECHANGED
);
279 /***********************************************************************
280 * UXTHEME_SetWindowProperty
282 * I'm using atoms as there may be large numbers of duplicated strings
283 * and they do the work of keeping memory down as a cause of that quite nicely
285 HRESULT
UXTHEME_SetWindowProperty(HWND hwnd
, ATOM aProp
, LPCWSTR pszValue
)
287 ATOM oldValue
= (ATOM
)(size_t)RemovePropW(hwnd
, MAKEINTATOMW(aProp
));
289 DeleteAtom(oldValue
);
291 ATOM atValue
= AddAtomW(pszValue
);
293 || !SetPropW(hwnd
, MAKEINTATOMW(aProp
), (LPWSTR
)MAKEINTATOMW(atValue
))) {
294 HRESULT hr
= HRESULT_FROM_WIN32(GetLastError());
295 if(atValue
) DeleteAtom(atValue
);
302 LPWSTR
UXTHEME_GetWindowProperty(HWND hwnd
, ATOM aProp
, LPWSTR pszBuffer
, int dwLen
)
304 ATOM atValue
= (ATOM
)(size_t)GetPropW(hwnd
, MAKEINTATOMW(aProp
));
306 if(GetAtomNameW(atValue
, pszBuffer
, dwLen
))
308 TRACE("property defined, but unable to get value\n");
313 /***********************************************************************
314 * OpenThemeData (UXTHEME.@)
316 HTHEME WINAPI
OpenThemeData(HWND hwnd
, LPCWSTR pszClassList
)
318 WCHAR szAppBuff
[256];
319 WCHAR szClassBuff
[256];
321 LPCWSTR pszUseClassList
;
323 TRACE("(%p,%s)\n", hwnd
, debugstr_w(pszClassList
));
327 pszAppName
= UXTHEME_GetWindowProperty(hwnd
, atSubAppName
, szAppBuff
, sizeof(szAppBuff
)/sizeof(szAppBuff
[0]));
328 /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */
329 pszUseClassList
= UXTHEME_GetWindowProperty(hwnd
, atSubIdList
, szClassBuff
, sizeof(szClassBuff
)/sizeof(szClassBuff
[0]));
331 pszUseClassList
= pszClassList
;
333 hTheme
= MSSTYLES_OpenThemeClass(pszAppName
, pszUseClassList
);
335 SetPropW(hwnd
, MAKEINTATOMW(atWindowTheme
), hTheme
);
339 /***********************************************************************
340 * GetWindowTheme (UXTHEME.@)
342 * Retrieve the last theme opened for a window
344 HTHEME WINAPI
GetWindowTheme(HWND hwnd
)
346 TRACE("(%p)\n", hwnd
);
347 return GetPropW(hwnd
, MAKEINTATOMW(atWindowTheme
));
350 /***********************************************************************
351 * SetWindowTheme (UXTHEME.@)
353 * Persistent through the life of the window, even after themes change
355 HRESULT WINAPI
SetWindowTheme(HWND hwnd
, LPCWSTR pszSubAppName
,
356 LPCWSTR pszSubIdList
)
359 TRACE("(%p,%s,%s)\n", hwnd
, debugstr_w(pszSubAppName
),
360 debugstr_w(pszSubIdList
));
361 hr
= UXTHEME_SetWindowProperty(hwnd
, atSubAppName
, pszSubAppName
);
363 hr
= UXTHEME_SetWindowProperty(hwnd
, atSubIdList
, pszSubIdList
);
365 UXTHEME_broadcast_msg (hwnd
, WM_THEMECHANGED
);
369 /***********************************************************************
370 * GetCurrentThemeName (UXTHEME.@)
372 HRESULT WINAPI
GetCurrentThemeName(LPWSTR pszThemeFileName
, int dwMaxNameChars
,
373 LPWSTR pszColorBuff
, int cchMaxColorChars
,
374 LPWSTR pszSizeBuff
, int cchMaxSizeChars
)
377 return E_PROP_ID_UNSUPPORTED
;
378 if(pszThemeFileName
) lstrcpynW(pszThemeFileName
, szCurrentTheme
, dwMaxNameChars
);
379 if(pszColorBuff
) lstrcpynW(pszColorBuff
, szCurrentColor
, cchMaxColorChars
);
380 if(pszSizeBuff
) lstrcpynW(pszSizeBuff
, szCurrentSize
, cchMaxSizeChars
);
384 /***********************************************************************
385 * GetThemeAppProperties (UXTHEME.@)
387 DWORD WINAPI
GetThemeAppProperties(void)
389 return dwThemeAppProperties
;
392 /***********************************************************************
393 * SetThemeAppProperties (UXTHEME.@)
395 void WINAPI
SetThemeAppProperties(DWORD dwFlags
)
397 TRACE("(0x%08lx)\n", dwFlags
);
398 dwThemeAppProperties
= dwFlags
;
401 /***********************************************************************
402 * CloseThemeData (UXTHEME.@)
404 HRESULT WINAPI
CloseThemeData(HTHEME hTheme
)
406 TRACE("(%p)\n", hTheme
);
409 return MSSTYLES_CloseThemeClass(hTheme
);
412 /***********************************************************************
413 * HitTestThemeBackground (UXTHEME.@)
415 HRESULT WINAPI
HitTestThemeBackground(HTHEME hTheme
, HDC hdc
, int iPartId
,
416 int iStateId
, DWORD dwOptions
,
417 const RECT
*pRect
, HRGN hrgn
,
418 POINT ptTest
, WORD
*pwHitTestCode
)
420 FIXME("%d %d 0x%08lx: stub\n", iPartId
, iStateId
, dwOptions
);
423 return ERROR_CALL_NOT_IMPLEMENTED
;
426 /***********************************************************************
427 * IsThemePartDefined (UXTHEME.@)
429 BOOL WINAPI
IsThemePartDefined(HTHEME hTheme
, int iPartId
, int iStateId
)
431 TRACE("(%p,%d,%d)\n", hTheme
, iPartId
, iStateId
);
433 SetLastError(E_HANDLE
);
436 if(MSSTYLES_FindPartState(hTheme
, iPartId
, iStateId
, NULL
))
441 /***********************************************************************
442 * GetThemeDocumentationProperty (UXTHEME.@)
444 * Try and retrieve the documentation property from string resources
445 * if that fails, get it from the [documentation] section of themes.ini
447 HRESULT WINAPI
GetThemeDocumentationProperty(LPCWSTR pszThemeName
,
448 LPCWSTR pszPropertyName
,
452 const WORD wDocToRes
[] = {
453 TMT_DISPLAYNAME
,5000,
467 TRACE("(%s,%s,%p,%d)\n", debugstr_w(pszThemeName
), debugstr_w(pszPropertyName
),
468 pszValueBuff
, cchMaxValChars
);
470 hr
= MSSTYLES_OpenThemeFile(pszThemeName
, NULL
, NULL
, &pt
);
471 if(FAILED(hr
)) return hr
;
473 /* Try to load from string resources */
474 hr
= E_PROP_ID_UNSUPPORTED
;
475 if(MSSTYLES_LookupProperty(pszPropertyName
, NULL
, &iDocId
)) {
476 for(i
=0; i
<sizeof(wDocToRes
)/sizeof(wDocToRes
[0]); i
+=2) {
477 if(wDocToRes
[i
] == iDocId
) {
478 if(LoadStringW(pt
->hTheme
, wDocToRes
[i
+1], pszValueBuff
, cchMaxValChars
)) {
485 /* If loading from string resource failed, try getting it from the theme.ini */
487 PUXINI_FILE uf
= MSSTYLES_GetThemeIni(pt
);
488 if(UXINI_FindSection(uf
, szIniDocumentation
)) {
491 if(UXINI_FindValue(uf
, pszPropertyName
, &lpValue
, &dwLen
)) {
492 lstrcpynW(pszValueBuff
, lpValue
, min(dwLen
+1,cchMaxValChars
));
499 MSSTYLES_CloseThemeFile(pt
);
503 /**********************************************************************
504 * Undocumented functions
507 /**********************************************************************
508 * QueryThemeServices (UXTHEME.1)
511 * some kind of status flag
513 DWORD WINAPI
QueryThemeServices()
516 return 3; /* This is what is returned under XP in most cases */
520 /**********************************************************************
521 * OpenThemeFile (UXTHEME.2)
523 * Opens a theme file, which can be used to change the current theme, etc
526 * pszThemeFileName Path to a msstyles theme file
527 * pszColorName Color defined in the theme, eg. NormalColor
528 * pszSizeName Size defined in the theme, eg. NormalSize
529 * hThemeFile Handle to theme file
531 HRESULT WINAPI
OpenThemeFile(LPCWSTR pszThemeFileName
, LPCWSTR pszColorName
,
532 LPCWSTR pszSizeName
, HTHEMEFILE
*hThemeFile
,
535 TRACE("(%s,%s,%s,%p,%ld)\n", debugstr_w(pszThemeFileName
),
536 debugstr_w(pszColorName
), debugstr_w(pszSizeName
),
537 hThemeFile
, unknown
);
538 return MSSTYLES_OpenThemeFile(pszThemeFileName
, pszColorName
, pszSizeName
, (PTHEME_FILE
*)hThemeFile
);
541 /**********************************************************************
542 * CloseThemeFile (UXTHEME.3)
544 * Releases theme file handle returned by OpenThemeFile
547 * hThemeFile Handle to theme file
549 HRESULT WINAPI
CloseThemeFile(HTHEMEFILE hThemeFile
)
551 TRACE("(%p)\n", hThemeFile
);
552 MSSTYLES_CloseThemeFile(hThemeFile
);
556 /**********************************************************************
557 * ApplyTheme (UXTHEME.4)
559 * Set a theme file to be the currently active theme
562 * hThemeFile Handle to theme file
564 * hWnd Window requesting the theme change
567 * I'm not sure what the second parameter is (the datatype is likely wrong), other then this:
570 * the theme is applied with the screen redrawing really badly (flickers)
571 * char b[] = "\0"; where \0 can be one or more of any character, makes no difference
572 * the theme is applied smoothly (screen does not flicker)
573 * char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference
574 * the function fails returning invalid parameter...very strange
576 HRESULT WINAPI
ApplyTheme(HTHEMEFILE hThemeFile
, char *unknown
, HWND hWnd
)
579 TRACE("(%p,%s,%p)\n", hThemeFile
, unknown
, hWnd
);
580 hr
= UXTHEME_SetActiveTheme(hThemeFile
);
581 UXTHEME_broadcast_msg (NULL
, WM_THEMECHANGED
);
585 /**********************************************************************
586 * GetThemeDefaults (UXTHEME.7)
588 * Get the default color & size for a theme
591 * pszThemeFileName Path to a msstyles theme file
592 * pszColorName Buffer to receive the default color name
593 * dwColorNameLen Length, in characters, of color name buffer
594 * pszSizeName Buffer to receive the default size name
595 * dwSizeNameLen Length, in characters, of size name buffer
597 HRESULT WINAPI
GetThemeDefaults(LPCWSTR pszThemeFileName
, LPWSTR pszColorName
,
598 DWORD dwColorNameLen
, LPWSTR pszSizeName
,
603 TRACE("(%s,%p,%ld,%p,%ld)\n", debugstr_w(pszThemeFileName
),
604 pszColorName
, dwColorNameLen
,
605 pszSizeName
, dwSizeNameLen
);
607 hr
= MSSTYLES_OpenThemeFile(pszThemeFileName
, NULL
, NULL
, &pt
);
608 if(FAILED(hr
)) return hr
;
610 lstrcpynW(pszColorName
, pt
->pszSelectedColor
, dwColorNameLen
);
611 lstrcpynW(pszSizeName
, pt
->pszSelectedSize
, dwSizeNameLen
);
613 MSSTYLES_CloseThemeFile(pt
);
617 /**********************************************************************
618 * EnumThemes (UXTHEME.8)
620 * Enumerate available themes, calls specified EnumThemeProc for each
621 * theme found. Passes lpData through to callback function.
624 * pszThemePath Path containing themes
625 * callback Called for each theme found in path
626 * lpData Passed through to callback
628 HRESULT WINAPI
EnumThemes(LPCWSTR pszThemePath
, EnumThemeProc callback
,
631 WCHAR szDir
[MAX_PATH
];
632 WCHAR szPath
[MAX_PATH
];
633 static const WCHAR szStar
[] = {'*','.','*','\0'};
634 static const WCHAR szFormat
[] = {'%','s','%','s','\\','%','s','.','m','s','s','t','y','l','e','s','\0'};
635 static const WCHAR szDisplayName
[] = {'d','i','s','p','l','a','y','n','a','m','e','\0'};
636 static const WCHAR szTooltip
[] = {'t','o','o','l','t','i','p','\0'};
640 WIN32_FIND_DATAW wfd
;
643 TRACE("(%s,%p,%p)\n", debugstr_w(pszThemePath
), callback
, lpData
);
645 if(!pszThemePath
|| !callback
)
648 lstrcpyW(szDir
, pszThemePath
);
649 PathAddBackslashW(szDir
);
651 lstrcpyW(szPath
, szDir
);
652 lstrcatW(szPath
, szStar
);
653 TRACE("searching %s\n", debugstr_w(szPath
));
655 hFind
= FindFirstFileW(szPath
, &wfd
);
656 if(hFind
!= INVALID_HANDLE_VALUE
) {
658 if(wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
659 && !(wfd
.cFileName
[0] == '.' && ((wfd
.cFileName
[1] == '.' && wfd
.cFileName
[2] == 0) || wfd
.cFileName
[1] == 0))) {
660 wsprintfW(szPath
, szFormat
, szDir
, wfd
.cFileName
, wfd
.cFileName
);
662 hr
= GetThemeDocumentationProperty(szPath
, szDisplayName
, szName
, sizeof(szName
)/sizeof(szName
[0]));
664 hr
= GetThemeDocumentationProperty(szPath
, szTooltip
, szTip
, sizeof(szTip
)/sizeof(szTip
[0]));
666 TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath
), debugstr_w(szName
), debugstr_w(szTip
), lpData
);
667 if(!callback(NULL
, szPath
, szName
, szTip
, NULL
, lpData
)) {
668 TRACE("callback ended enum\n");
673 } while(FindNextFileW(hFind
, &wfd
));
680 /**********************************************************************
681 * EnumThemeColors (UXTHEME.9)
683 * Enumerate theme colors available with a particular size
686 * pszThemeFileName Path to a msstyles theme file
687 * pszSizeName Theme size to enumerate available colors
688 * If NULL the default theme size is used
689 * dwColorNum Color index to retrieve, increment from 0
690 * pszColorName Output color name
694 * E_PROP_ID_UNSUPPORTED when dwColorName does not refer to a color
695 * or when pszSizeName does not refer to a valid size
698 * XP fails with E_POINTER when pszColorName points to a buffer smaller then 605
701 * Not very efficient that I'm opening & validating the theme every call, but
702 * this is undocumented and almost never called..
703 * (and this is how windows works too)
705 HRESULT WINAPI
EnumThemeColors(LPWSTR pszThemeFileName
, LPWSTR pszSizeName
,
706 DWORD dwColorNum
, LPWSTR pszColorName
)
711 TRACE("(%s,%s,%ld)\n", debugstr_w(pszThemeFileName
),
712 debugstr_w(pszSizeName
), dwColorNum
);
714 hr
= MSSTYLES_OpenThemeFile(pszThemeFileName
, NULL
, pszSizeName
, &pt
);
715 if(FAILED(hr
)) return hr
;
717 tmp
= pt
->pszAvailColors
;
718 while(dwColorNum
&& *tmp
) {
720 tmp
+= lstrlenW(tmp
)+1;
722 if(!dwColorNum
&& *tmp
) {
723 TRACE("%s\n", debugstr_w(tmp
));
724 lstrcpyW(pszColorName
, tmp
);
727 hr
= E_PROP_ID_UNSUPPORTED
;
729 MSSTYLES_CloseThemeFile(pt
);
733 /**********************************************************************
734 * EnumThemeSizes (UXTHEME.10)
736 * Enumerate theme colors available with a particular size
739 * pszThemeFileName Path to a msstyles theme file
740 * pszColorName Theme color to enumerate available sizes
741 * If NULL the default theme color is used
742 * dwSizeNum Size index to retrieve, increment from 0
743 * pszSizeName Output size name
747 * E_PROP_ID_UNSUPPORTED when dwSizeName does not refer to a size
748 * or when pszColorName does not refer to a valid color
751 * XP fails with E_POINTER when pszSizeName points to a buffer smaller then 605
754 * Not very efficient that I'm opening & validating the theme every call, but
755 * this is undocumented and almost never called..
756 * (and this is how windows works too)
758 HRESULT WINAPI
EnumThemeSizes(LPWSTR pszThemeFileName
, LPWSTR pszColorName
,
759 DWORD dwSizeNum
, LPWSTR pszSizeName
)
764 TRACE("(%s,%s,%ld)\n", debugstr_w(pszThemeFileName
),
765 debugstr_w(pszColorName
), dwSizeNum
);
767 hr
= MSSTYLES_OpenThemeFile(pszThemeFileName
, pszColorName
, NULL
, &pt
);
768 if(FAILED(hr
)) return hr
;
770 tmp
= pt
->pszAvailSizes
;
771 while(dwSizeNum
&& *tmp
) {
773 tmp
+= lstrlenW(tmp
)+1;
775 if(!dwSizeNum
&& *tmp
) {
776 TRACE("%s\n", debugstr_w(tmp
));
777 lstrcpyW(pszSizeName
, tmp
);
780 hr
= E_PROP_ID_UNSUPPORTED
;
782 MSSTYLES_CloseThemeFile(pt
);
786 /**********************************************************************
787 * ParseThemeIniFile (UXTHEME.11)
789 * Enumerate data in a theme INI file.
792 * pszIniFileName Path to a theme ini file
793 * pszUnknown Cannot be NULL, L"" is valid
794 * callback Called for each found entry
795 * lpData Passed through to callback
799 * 0x800706488 (Unknown property) when enumeration is canceled from callback
802 * When pszUnknown is NULL the callback is never called, the value does not seem to surve
805 HRESULT WINAPI
ParseThemeIniFile(LPCWSTR pszIniFileName
, LPWSTR pszUnknown
,
806 ParseThemeIniFileProc callback
, LPVOID lpData
)
808 FIXME("%s %s: stub\n", debugstr_w(pszIniFileName
), debugstr_w(pszUnknown
));
809 return ERROR_CALL_NOT_IMPLEMENTED
;
812 /**********************************************************************
813 * CheckThemeSignature (UXTHEME.29)
815 * Validates the signature of a theme file
818 * pszIniFileName Path to a theme file
820 HRESULT WINAPI
CheckThemeSignature(LPCWSTR pszThemeFileName
)
824 TRACE("(%s)\n", debugstr_w(pszThemeFileName
));
825 hr
= MSSTYLES_OpenThemeFile(pszThemeFileName
, NULL
, NULL
, &pt
);
828 MSSTYLES_CloseThemeFile(pt
);