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
;
65 ATOM atDialogThemeEnabled
;
67 BOOL bThemeActive
= FALSE
;
68 WCHAR szCurrentTheme
[MAX_PATH
];
69 WCHAR szCurrentColor
[64];
70 WCHAR szCurrentSize
[64];
72 /***********************************************************************/
74 static BOOL CALLBACK
UXTHEME_broadcast_msg_enumchild (HWND hWnd
, LPARAM msg
)
76 PostMessageW(hWnd
, msg
, 0, 0);
80 /* Broadcast a message to *all* windows, including children */
81 static BOOL CALLBACK
UXTHEME_broadcast_msg (HWND hWnd
, LPARAM msg
)
85 EnumWindows (UXTHEME_broadcast_msg
, msg
);
89 PostMessageW(hWnd
, msg
, 0, 0);
90 EnumChildWindows (hWnd
, UXTHEME_broadcast_msg_enumchild
, msg
);
95 /***********************************************************************
98 * Set the current active theme from the registry
100 static void UXTHEME_LoadTheme(void)
108 /* Get current theme configuration */
109 if(!RegOpenKeyW(HKEY_CURRENT_USER
, szThemeManager
, &hKey
)) {
110 TRACE("Loading theme config\n");
111 buffsize
= sizeof(tmp
)/sizeof(tmp
[0]);
112 if(!RegQueryValueExW(hKey
, szThemeActive
, NULL
, NULL
, (LPBYTE
)tmp
, &buffsize
)) {
113 bThemeActive
= (tmp
[0] != '0');
116 bThemeActive
= FALSE
;
117 TRACE("Failed to get ThemeActive: %ld\n", GetLastError());
119 buffsize
= sizeof(szCurrentColor
)/sizeof(szCurrentColor
[0]);
120 if(RegQueryValueExW(hKey
, szColorName
, NULL
, NULL
, (LPBYTE
)szCurrentColor
, &buffsize
))
121 szCurrentColor
[0] = '\0';
122 buffsize
= sizeof(szCurrentSize
)/sizeof(szCurrentSize
[0]);
123 if(RegQueryValueExW(hKey
, szSizeName
, NULL
, NULL
, (LPBYTE
)szCurrentSize
, &buffsize
))
124 szCurrentSize
[0] = '\0';
125 if(SHRegGetPathW(hKey
, NULL
, szDllName
, szCurrentTheme
, 0))
126 szCurrentTheme
[0] = '\0';
130 TRACE("Failed to open theme registry key\n");
133 /* Make sure the theme requested is actually valid */
134 hr
= MSSTYLES_OpenThemeFile(szCurrentTheme
,
135 szCurrentColor
[0]?szCurrentColor
:NULL
,
136 szCurrentSize
[0]?szCurrentSize
:NULL
,
139 bThemeActive
= FALSE
;
140 szCurrentTheme
[0] = '\0';
141 szCurrentColor
[0] = '\0';
142 szCurrentSize
[0] = '\0';
145 /* Make sure the global color & size match the theme */
146 lstrcpynW(szCurrentColor
, pt
->pszSelectedColor
, sizeof(szCurrentColor
)/sizeof(szCurrentColor
[0]));
147 lstrcpynW(szCurrentSize
, pt
->pszSelectedSize
, sizeof(szCurrentSize
)/sizeof(szCurrentSize
[0]));
149 MSSTYLES_SetActiveTheme(pt
);
150 TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme
),
151 debugstr_w(szCurrentColor
), debugstr_w(szCurrentSize
));
152 MSSTYLES_CloseThemeFile(pt
);
156 MSSTYLES_SetActiveTheme(NULL
);
157 TRACE("Themeing not active\n");
161 /***********************************************************************
162 * UXTHEME_SetActiveTheme
164 * Change the current active theme
166 HRESULT
UXTHEME_SetActiveTheme(PTHEME_FILE tf
)
172 hr
= MSSTYLES_SetActiveTheme(tf
);
177 lstrcpynW(szCurrentTheme
, tf
->szThemeFile
, sizeof(szCurrentTheme
)/sizeof(szCurrentTheme
[0]));
178 lstrcpynW(szCurrentColor
, tf
->pszSelectedColor
, sizeof(szCurrentColor
)/sizeof(szCurrentColor
[0]));
179 lstrcpynW(szCurrentSize
, tf
->pszSelectedSize
, sizeof(szCurrentSize
)/sizeof(szCurrentSize
[0]));
182 bThemeActive
= FALSE
;
183 szCurrentTheme
[0] = '\0';
184 szCurrentColor
[0] = '\0';
185 szCurrentSize
[0] = '\0';
188 TRACE("Writing theme config to registry\n");
189 if(!RegCreateKeyW(HKEY_CURRENT_USER
, szThemeManager
, &hKey
)) {
190 tmp
[0] = bThemeActive
?'1':'0';
192 RegSetValueExW(hKey
, szThemeActive
, 0, REG_SZ
, (const BYTE
*)tmp
, sizeof(WCHAR
)*2);
194 RegSetValueExW(hKey
, szColorName
, 0, REG_SZ
, (const BYTE
*)szCurrentColor
,
195 (lstrlenW(szCurrentColor
)+1)*sizeof(WCHAR
));
196 RegSetValueExW(hKey
, szSizeName
, 0, REG_SZ
, (const BYTE
*)szCurrentSize
,
197 (lstrlenW(szCurrentSize
)+1)*sizeof(WCHAR
));
198 RegSetValueExW(hKey
, szDllName
, 0, REG_SZ
, (const BYTE
*)szCurrentTheme
,
199 (lstrlenW(szCurrentTheme
)+1)*sizeof(WCHAR
));
202 RegDeleteValueW(hKey
, szColorName
);
203 RegDeleteValueW(hKey
, szSizeName
);
204 RegDeleteValueW(hKey
, szDllName
);
210 TRACE("Failed to open theme registry key\n");
214 /***********************************************************************
217 void UXTHEME_InitSystem(HINSTANCE hInst
)
219 static const WCHAR szWindowTheme
[] = {
220 'u','x','_','t','h','e','m','e','\0'
222 static const WCHAR szSubAppName
[] = {
223 'u','x','_','s','u','b','a','p','p','\0'
225 static const WCHAR szSubIdList
[] = {
226 'u','x','_','s','u','b','i','d','l','s','t','\0'
228 static const WCHAR szDialogThemeEnabled
[] = {
229 'u','x','_','d','i','a','l','o','g','t','h','e','m','e','\0'
234 atWindowTheme
= GlobalAddAtomW(szWindowTheme
);
235 atSubAppName
= GlobalAddAtomW(szSubAppName
);
236 atSubIdList
= GlobalAddAtomW(szSubIdList
);
237 atDialogThemeEnabled
= GlobalAddAtomW(szDialogThemeEnabled
);
242 /***********************************************************************
243 * IsAppThemed (UXTHEME.@)
245 BOOL WINAPI
IsAppThemed(void)
247 return IsThemeActive();
250 /***********************************************************************
251 * IsThemeActive (UXTHEME.@)
253 BOOL WINAPI
IsThemeActive(void)
259 /***********************************************************************
260 * EnableTheming (UXTHEME.@)
263 * This is a global and persistent change
265 HRESULT WINAPI
EnableTheming(BOOL fEnable
)
268 WCHAR szEnabled
[] = {'0','\0'};
270 TRACE("(%d)\n", fEnable
);
272 if(fEnable
!= bThemeActive
) {
273 bThemeActive
= fEnable
;
274 if(bThemeActive
) szEnabled
[0] = '1';
275 if(!RegOpenKeyW(HKEY_CURRENT_USER
, szThemeManager
, &hKey
)) {
276 RegSetValueExW(hKey
, szThemeActive
, 0, REG_SZ
, (LPBYTE
)szEnabled
, sizeof(WCHAR
));
279 UXTHEME_broadcast_msg (NULL
, WM_THEMECHANGED
);
284 /***********************************************************************
285 * UXTHEME_SetWindowProperty
287 * I'm using atoms as there may be large numbers of duplicated strings
288 * and they do the work of keeping memory down as a cause of that quite nicely
290 HRESULT
UXTHEME_SetWindowProperty(HWND hwnd
, ATOM aProp
, LPCWSTR pszValue
)
292 ATOM oldValue
= (ATOM
)(size_t)RemovePropW(hwnd
, MAKEINTATOMW(aProp
));
294 DeleteAtom(oldValue
);
296 ATOM atValue
= AddAtomW(pszValue
);
298 || !SetPropW(hwnd
, MAKEINTATOMW(aProp
), (LPWSTR
)MAKEINTATOMW(atValue
))) {
299 HRESULT hr
= HRESULT_FROM_WIN32(GetLastError());
300 if(atValue
) DeleteAtom(atValue
);
307 LPWSTR
UXTHEME_GetWindowProperty(HWND hwnd
, ATOM aProp
, LPWSTR pszBuffer
, int dwLen
)
309 ATOM atValue
= (ATOM
)(size_t)GetPropW(hwnd
, MAKEINTATOMW(aProp
));
311 if(GetAtomNameW(atValue
, pszBuffer
, dwLen
))
313 TRACE("property defined, but unable to get value\n");
318 /***********************************************************************
319 * OpenThemeData (UXTHEME.@)
321 HTHEME WINAPI
OpenThemeData(HWND hwnd
, LPCWSTR pszClassList
)
323 WCHAR szAppBuff
[256];
324 WCHAR szClassBuff
[256];
326 LPCWSTR pszUseClassList
;
327 HTHEME hTheme
= NULL
;
328 TRACE("(%p,%s)", hwnd
, debugstr_w(pszClassList
));
332 pszAppName
= UXTHEME_GetWindowProperty(hwnd
, atSubAppName
, szAppBuff
, sizeof(szAppBuff
)/sizeof(szAppBuff
[0]));
333 /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */
334 pszUseClassList
= UXTHEME_GetWindowProperty(hwnd
, atSubIdList
, szClassBuff
, sizeof(szClassBuff
)/sizeof(szClassBuff
[0]));
336 pszUseClassList
= pszClassList
;
339 hTheme
= MSSTYLES_OpenThemeClass(pszAppName
, pszUseClassList
);
342 SetPropW(hwnd
, MAKEINTATOMW(atWindowTheme
), hTheme
);
343 TRACE(" = %p\n", hTheme
);
347 /***********************************************************************
348 * GetWindowTheme (UXTHEME.@)
350 * Retrieve the last theme opened for a window
352 HTHEME WINAPI
GetWindowTheme(HWND hwnd
)
354 TRACE("(%p)\n", hwnd
);
355 return GetPropW(hwnd
, MAKEINTATOMW(atWindowTheme
));
358 /***********************************************************************
359 * SetWindowTheme (UXTHEME.@)
361 * Persistent through the life of the window, even after themes change
363 HRESULT WINAPI
SetWindowTheme(HWND hwnd
, LPCWSTR pszSubAppName
,
364 LPCWSTR pszSubIdList
)
367 TRACE("(%p,%s,%s)\n", hwnd
, debugstr_w(pszSubAppName
),
368 debugstr_w(pszSubIdList
));
369 hr
= UXTHEME_SetWindowProperty(hwnd
, atSubAppName
, pszSubAppName
);
371 hr
= UXTHEME_SetWindowProperty(hwnd
, atSubIdList
, pszSubIdList
);
373 UXTHEME_broadcast_msg (hwnd
, WM_THEMECHANGED
);
377 /***********************************************************************
378 * GetCurrentThemeName (UXTHEME.@)
380 HRESULT WINAPI
GetCurrentThemeName(LPWSTR pszThemeFileName
, int dwMaxNameChars
,
381 LPWSTR pszColorBuff
, int cchMaxColorChars
,
382 LPWSTR pszSizeBuff
, int cchMaxSizeChars
)
385 return E_PROP_ID_UNSUPPORTED
;
386 if(pszThemeFileName
) lstrcpynW(pszThemeFileName
, szCurrentTheme
, dwMaxNameChars
);
387 if(pszColorBuff
) lstrcpynW(pszColorBuff
, szCurrentColor
, cchMaxColorChars
);
388 if(pszSizeBuff
) lstrcpynW(pszSizeBuff
, szCurrentSize
, cchMaxSizeChars
);
392 /***********************************************************************
393 * GetThemeAppProperties (UXTHEME.@)
395 DWORD WINAPI
GetThemeAppProperties(void)
397 return dwThemeAppProperties
;
400 /***********************************************************************
401 * SetThemeAppProperties (UXTHEME.@)
403 void WINAPI
SetThemeAppProperties(DWORD dwFlags
)
405 TRACE("(0x%08lx)\n", dwFlags
);
406 dwThemeAppProperties
= dwFlags
;
409 /***********************************************************************
410 * CloseThemeData (UXTHEME.@)
412 HRESULT WINAPI
CloseThemeData(HTHEME hTheme
)
414 TRACE("(%p)\n", hTheme
);
417 return MSSTYLES_CloseThemeClass(hTheme
);
420 /***********************************************************************
421 * HitTestThemeBackground (UXTHEME.@)
423 HRESULT WINAPI
HitTestThemeBackground(HTHEME hTheme
, HDC hdc
, int iPartId
,
424 int iStateId
, DWORD dwOptions
,
425 const RECT
*pRect
, HRGN hrgn
,
426 POINT ptTest
, WORD
*pwHitTestCode
)
428 FIXME("%d %d 0x%08lx: stub\n", iPartId
, iStateId
, dwOptions
);
431 return ERROR_CALL_NOT_IMPLEMENTED
;
434 /***********************************************************************
435 * IsThemePartDefined (UXTHEME.@)
437 BOOL WINAPI
IsThemePartDefined(HTHEME hTheme
, int iPartId
, int iStateId
)
439 TRACE("(%p,%d,%d)\n", hTheme
, iPartId
, iStateId
);
441 SetLastError(E_HANDLE
);
444 if(MSSTYLES_FindPartState(hTheme
, iPartId
, iStateId
, NULL
))
449 /***********************************************************************
450 * GetThemeDocumentationProperty (UXTHEME.@)
452 * Try and retrieve the documentation property from string resources
453 * if that fails, get it from the [documentation] section of themes.ini
455 HRESULT WINAPI
GetThemeDocumentationProperty(LPCWSTR pszThemeName
,
456 LPCWSTR pszPropertyName
,
460 const WORD wDocToRes
[] = {
461 TMT_DISPLAYNAME
,5000,
475 TRACE("(%s,%s,%p,%d)\n", debugstr_w(pszThemeName
), debugstr_w(pszPropertyName
),
476 pszValueBuff
, cchMaxValChars
);
478 hr
= MSSTYLES_OpenThemeFile(pszThemeName
, NULL
, NULL
, &pt
);
479 if(FAILED(hr
)) return hr
;
481 /* Try to load from string resources */
482 hr
= E_PROP_ID_UNSUPPORTED
;
483 if(MSSTYLES_LookupProperty(pszPropertyName
, NULL
, &iDocId
)) {
484 for(i
=0; i
<sizeof(wDocToRes
)/sizeof(wDocToRes
[0]); i
+=2) {
485 if(wDocToRes
[i
] == iDocId
) {
486 if(LoadStringW(pt
->hTheme
, wDocToRes
[i
+1], pszValueBuff
, cchMaxValChars
)) {
493 /* If loading from string resource failed, try getting it from the theme.ini */
495 PUXINI_FILE uf
= MSSTYLES_GetThemeIni(pt
);
496 if(UXINI_FindSection(uf
, szIniDocumentation
)) {
499 if(UXINI_FindValue(uf
, pszPropertyName
, &lpValue
, &dwLen
)) {
500 lstrcpynW(pszValueBuff
, lpValue
, min(dwLen
+1,cchMaxValChars
));
507 MSSTYLES_CloseThemeFile(pt
);
511 /**********************************************************************
512 * Undocumented functions
515 /**********************************************************************
516 * QueryThemeServices (UXTHEME.1)
519 * some kind of status flag
521 DWORD WINAPI
QueryThemeServices()
524 return 3; /* This is what is returned under XP in most cases */
528 /**********************************************************************
529 * OpenThemeFile (UXTHEME.2)
531 * Opens a theme file, which can be used to change the current theme, etc
534 * pszThemeFileName Path to a msstyles theme file
535 * pszColorName Color defined in the theme, eg. NormalColor
536 * pszSizeName Size defined in the theme, eg. NormalSize
537 * hThemeFile Handle to theme file
539 HRESULT WINAPI
OpenThemeFile(LPCWSTR pszThemeFileName
, LPCWSTR pszColorName
,
540 LPCWSTR pszSizeName
, HTHEMEFILE
*hThemeFile
,
543 TRACE("(%s,%s,%s,%p,%ld)\n", debugstr_w(pszThemeFileName
),
544 debugstr_w(pszColorName
), debugstr_w(pszSizeName
),
545 hThemeFile
, unknown
);
546 return MSSTYLES_OpenThemeFile(pszThemeFileName
, pszColorName
, pszSizeName
, (PTHEME_FILE
*)hThemeFile
);
549 /**********************************************************************
550 * CloseThemeFile (UXTHEME.3)
552 * Releases theme file handle returned by OpenThemeFile
555 * hThemeFile Handle to theme file
557 HRESULT WINAPI
CloseThemeFile(HTHEMEFILE hThemeFile
)
559 TRACE("(%p)\n", hThemeFile
);
560 MSSTYLES_CloseThemeFile(hThemeFile
);
564 /**********************************************************************
565 * ApplyTheme (UXTHEME.4)
567 * Set a theme file to be the currently active theme
570 * hThemeFile Handle to theme file
572 * hWnd Window requesting the theme change
575 * I'm not sure what the second parameter is (the datatype is likely wrong), other then this:
578 * the theme is applied with the screen redrawing really badly (flickers)
579 * char b[] = "\0"; where \0 can be one or more of any character, makes no difference
580 * the theme is applied smoothly (screen does not flicker)
581 * char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference
582 * the function fails returning invalid parameter...very strange
584 HRESULT WINAPI
ApplyTheme(HTHEMEFILE hThemeFile
, char *unknown
, HWND hWnd
)
587 TRACE("(%p,%s,%p)\n", hThemeFile
, unknown
, hWnd
);
588 hr
= UXTHEME_SetActiveTheme(hThemeFile
);
589 UXTHEME_broadcast_msg (NULL
, WM_THEMECHANGED
);
593 /**********************************************************************
594 * GetThemeDefaults (UXTHEME.7)
596 * Get the default color & size for a theme
599 * pszThemeFileName Path to a msstyles theme file
600 * pszColorName Buffer to receive the default color name
601 * dwColorNameLen Length, in characters, of color name buffer
602 * pszSizeName Buffer to receive the default size name
603 * dwSizeNameLen Length, in characters, of size name buffer
605 HRESULT WINAPI
GetThemeDefaults(LPCWSTR pszThemeFileName
, LPWSTR pszColorName
,
606 DWORD dwColorNameLen
, LPWSTR pszSizeName
,
611 TRACE("(%s,%p,%ld,%p,%ld)\n", debugstr_w(pszThemeFileName
),
612 pszColorName
, dwColorNameLen
,
613 pszSizeName
, dwSizeNameLen
);
615 hr
= MSSTYLES_OpenThemeFile(pszThemeFileName
, NULL
, NULL
, &pt
);
616 if(FAILED(hr
)) return hr
;
618 lstrcpynW(pszColorName
, pt
->pszSelectedColor
, dwColorNameLen
);
619 lstrcpynW(pszSizeName
, pt
->pszSelectedSize
, dwSizeNameLen
);
621 MSSTYLES_CloseThemeFile(pt
);
625 /**********************************************************************
626 * EnumThemes (UXTHEME.8)
628 * Enumerate available themes, calls specified EnumThemeProc for each
629 * theme found. Passes lpData through to callback function.
632 * pszThemePath Path containing themes
633 * callback Called for each theme found in path
634 * lpData Passed through to callback
636 HRESULT WINAPI
EnumThemes(LPCWSTR pszThemePath
, EnumThemeProc callback
,
639 WCHAR szDir
[MAX_PATH
];
640 WCHAR szPath
[MAX_PATH
];
641 static const WCHAR szStar
[] = {'*','.','*','\0'};
642 static const WCHAR szFormat
[] = {'%','s','%','s','\\','%','s','.','m','s','s','t','y','l','e','s','\0'};
643 static const WCHAR szDisplayName
[] = {'d','i','s','p','l','a','y','n','a','m','e','\0'};
644 static const WCHAR szTooltip
[] = {'t','o','o','l','t','i','p','\0'};
648 WIN32_FIND_DATAW wfd
;
651 TRACE("(%s,%p,%p)\n", debugstr_w(pszThemePath
), callback
, lpData
);
653 if(!pszThemePath
|| !callback
)
656 lstrcpyW(szDir
, pszThemePath
);
657 PathAddBackslashW(szDir
);
659 lstrcpyW(szPath
, szDir
);
660 lstrcatW(szPath
, szStar
);
661 TRACE("searching %s\n", debugstr_w(szPath
));
663 hFind
= FindFirstFileW(szPath
, &wfd
);
664 if(hFind
!= INVALID_HANDLE_VALUE
) {
666 if(wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
667 && !(wfd
.cFileName
[0] == '.' && ((wfd
.cFileName
[1] == '.' && wfd
.cFileName
[2] == 0) || wfd
.cFileName
[1] == 0))) {
668 wsprintfW(szPath
, szFormat
, szDir
, wfd
.cFileName
, wfd
.cFileName
);
670 hr
= GetThemeDocumentationProperty(szPath
, szDisplayName
, szName
, sizeof(szName
)/sizeof(szName
[0]));
672 hr
= GetThemeDocumentationProperty(szPath
, szTooltip
, szTip
, sizeof(szTip
)/sizeof(szTip
[0]));
674 TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath
), debugstr_w(szName
), debugstr_w(szTip
), lpData
);
675 if(!callback(NULL
, szPath
, szName
, szTip
, NULL
, lpData
)) {
676 TRACE("callback ended enum\n");
681 } while(FindNextFileW(hFind
, &wfd
));
688 /**********************************************************************
689 * EnumThemeColors (UXTHEME.9)
691 * Enumerate theme colors available with a particular size
694 * pszThemeFileName Path to a msstyles theme file
695 * pszSizeName Theme size to enumerate available colors
696 * If NULL the default theme size is used
697 * dwColorNum Color index to retrieve, increment from 0
698 * pszColorName Output color name
702 * E_PROP_ID_UNSUPPORTED when dwColorName does not refer to a color
703 * or when pszSizeName does not refer to a valid size
706 * XP fails with E_POINTER when pszColorName points to a buffer smaller then 605
709 * Not very efficient that I'm opening & validating the theme every call, but
710 * this is undocumented and almost never called..
711 * (and this is how windows works too)
713 HRESULT WINAPI
EnumThemeColors(LPWSTR pszThemeFileName
, LPWSTR pszSizeName
,
714 DWORD dwColorNum
, LPWSTR pszColorName
)
719 TRACE("(%s,%s,%ld)\n", debugstr_w(pszThemeFileName
),
720 debugstr_w(pszSizeName
), dwColorNum
);
722 hr
= MSSTYLES_OpenThemeFile(pszThemeFileName
, NULL
, pszSizeName
, &pt
);
723 if(FAILED(hr
)) return hr
;
725 tmp
= pt
->pszAvailColors
;
726 while(dwColorNum
&& *tmp
) {
728 tmp
+= lstrlenW(tmp
)+1;
730 if(!dwColorNum
&& *tmp
) {
731 TRACE("%s\n", debugstr_w(tmp
));
732 lstrcpyW(pszColorName
, tmp
);
735 hr
= E_PROP_ID_UNSUPPORTED
;
737 MSSTYLES_CloseThemeFile(pt
);
741 /**********************************************************************
742 * EnumThemeSizes (UXTHEME.10)
744 * Enumerate theme colors available with a particular size
747 * pszThemeFileName Path to a msstyles theme file
748 * pszColorName Theme color to enumerate available sizes
749 * If NULL the default theme color is used
750 * dwSizeNum Size index to retrieve, increment from 0
751 * pszSizeName Output size name
755 * E_PROP_ID_UNSUPPORTED when dwSizeName does not refer to a size
756 * or when pszColorName does not refer to a valid color
759 * XP fails with E_POINTER when pszSizeName points to a buffer smaller then 605
762 * Not very efficient that I'm opening & validating the theme every call, but
763 * this is undocumented and almost never called..
764 * (and this is how windows works too)
766 HRESULT WINAPI
EnumThemeSizes(LPWSTR pszThemeFileName
, LPWSTR pszColorName
,
767 DWORD dwSizeNum
, LPWSTR pszSizeName
)
772 TRACE("(%s,%s,%ld)\n", debugstr_w(pszThemeFileName
),
773 debugstr_w(pszColorName
), dwSizeNum
);
775 hr
= MSSTYLES_OpenThemeFile(pszThemeFileName
, pszColorName
, NULL
, &pt
);
776 if(FAILED(hr
)) return hr
;
778 tmp
= pt
->pszAvailSizes
;
779 while(dwSizeNum
&& *tmp
) {
781 tmp
+= lstrlenW(tmp
)+1;
783 if(!dwSizeNum
&& *tmp
) {
784 TRACE("%s\n", debugstr_w(tmp
));
785 lstrcpyW(pszSizeName
, tmp
);
788 hr
= E_PROP_ID_UNSUPPORTED
;
790 MSSTYLES_CloseThemeFile(pt
);
794 /**********************************************************************
795 * ParseThemeIniFile (UXTHEME.11)
797 * Enumerate data in a theme INI file.
800 * pszIniFileName Path to a theme ini file
801 * pszUnknown Cannot be NULL, L"" is valid
802 * callback Called for each found entry
803 * lpData Passed through to callback
807 * 0x800706488 (Unknown property) when enumeration is canceled from callback
810 * When pszUnknown is NULL the callback is never called, the value does not seem to surve
813 HRESULT WINAPI
ParseThemeIniFile(LPCWSTR pszIniFileName
, LPWSTR pszUnknown
,
814 ParseThemeIniFileProc callback
, LPVOID lpData
)
816 FIXME("%s %s: stub\n", debugstr_w(pszIniFileName
), debugstr_w(pszUnknown
));
817 return ERROR_CALL_NOT_IMPLEMENTED
;
820 /**********************************************************************
821 * CheckThemeSignature (UXTHEME.29)
823 * Validates the signature of a theme file
826 * pszIniFileName Path to a theme file
828 HRESULT WINAPI
CheckThemeSignature(LPCWSTR pszThemeFileName
)
832 TRACE("(%s)\n", debugstr_w(pszThemeFileName
));
833 hr
= MSSTYLES_OpenThemeFile(pszThemeFileName
, NULL
, NULL
, &pt
);
836 MSSTYLES_CloseThemeFile(pt
);