ReactOS 0.4.16-dev-823-g9a093ec
system.c
Go to the documentation of this file.
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
23#include <stdio.h>
24#include <winreg.h>
25#include <uxundoc.h>
26
28
29/***********************************************************************
30 * Defines and global variables
31 */
32
33static const WCHAR szThemeManager[] = {
34 'S','o','f','t','w','a','r','e','\\',
35 'M','i','c','r','o','s','o','f','t','\\',
36 'W','i','n','d','o','w','s','\\',
37 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
38 'T','h','e','m','e','M','a','n','a','g','e','r','\0'
39};
40static const WCHAR szThemeActive[] = {'T','h','e','m','e','A','c','t','i','v','e','\0'};
41static const WCHAR szSizeName[] = {'S','i','z','e','N','a','m','e','\0'};
42static const WCHAR szColorName[] = {'C','o','l','o','r','N','a','m','e','\0'};
43static const WCHAR szDllName[] = {'D','l','l','N','a','m','e','\0'};
44
45static const WCHAR szIniDocumentation[] = {'d','o','c','u','m','e','n','t','a','t','i','o','n','\0'};
46
49
50static DWORD dwThemeAppProperties = STAP_ALLOW_NONCLIENT | STAP_ALLOW_CONTROLS;
55
57
60
61/***********************************************************************/
62
64{
65 SendMessageW(hWnd, WM_THEMECHANGED, enable, 0);
66 return TRUE;
67}
68
69/* Broadcast WM_THEMECHANGED to *all* windows, including children */
71{
72 if (hWnd == NULL)
73 {
75 }
76 else
77 {
80 }
81 return TRUE;
82}
83
84/* At the end of the day this is a subset of what SHRegGetPath() does - copied
85 * here to avoid linking against shlwapi. */
88{
89 DWORD dwRet, dwType, dwUnExpDataLen = MAX_PATH * sizeof(WCHAR), dwExpDataLen;
90
91 TRACE("(hkey=%p,%s,%p)\n", hKey, debugstr_w(lpszValue),
92 pvData);
93
94 dwRet = RegQueryValueExW(hKey, lpszValue, 0, &dwType, pvData, &dwUnExpDataLen);
95 if (dwRet!=ERROR_SUCCESS && dwRet!=ERROR_MORE_DATA)
96 return dwRet;
97
98 if (dwType == REG_EXPAND_SZ)
99 {
100 DWORD nBytesToAlloc;
101
102 /* Expand type REG_EXPAND_SZ into REG_SZ */
103 LPWSTR szData;
104
105 /* If the caller didn't supply a buffer or the buffer is too small we have
106 * to allocate our own
107 */
108 if (dwRet == ERROR_MORE_DATA)
109 {
110 WCHAR cNull = '\0';
111 nBytesToAlloc = dwUnExpDataLen;
112
113 szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc);
114 RegQueryValueExW (hKey, lpszValue, 0, NULL, (LPBYTE)szData, &nBytesToAlloc);
115 dwExpDataLen = ExpandEnvironmentStringsW(szData, &cNull, 1);
116 dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
117 LocalFree(szData);
118 }
119 else
120 {
121 nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR);
122 szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc );
123 lstrcpyW(szData, pvData);
124 dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, MAX_PATH );
125 if (dwExpDataLen > MAX_PATH) dwRet = ERROR_MORE_DATA;
126 dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
127 LocalFree(szData);
128 }
129 }
130
131 return dwRet;
132}
133
135{
140 {
143 }
144 return S_OK;
145}
146
147static BOOL bIsThemeActive(LPCWSTR pszTheme, LPCWSTR pszColor, LPCWSTR pszSize)
148{
149 if (g_ActiveThemeFile == NULL)
150 return FALSE;
151
152 if (wcscmp(pszTheme, g_ActiveThemeFile->szThemeFile) != 0)
153 return FALSE;
154
155 if (!pszColor[0])
156 {
158 return FALSE;
159 }
160 else
161 {
162 if (wcscmp(pszColor, g_ActiveThemeFile->pszSelectedColor) != 0)
163 return FALSE;
164 }
165
166 if (!pszSize[0])
167 {
169 return FALSE;
170 }
171 else
172 {
173 if (wcscmp(pszSize, g_ActiveThemeFile->pszSelectedSize) != 0)
174 return FALSE;
175 }
176
177 return TRUE;
178}
179
180/***********************************************************************
181 * UXTHEME_LoadTheme
182 *
183 * Set the current active theme from the registry
184 */
186{
187 HKEY hKey;
188 DWORD buffsize;
189 HRESULT hr;
190 WCHAR tmp[10];
192 WCHAR szCurrentTheme[MAX_PATH];
193 WCHAR szCurrentColor[64];
194 WCHAR szCurrentSize[64];
196
197 if ((bLoad != FALSE) && g_bThemeHooksActive)
198 {
199 /* Get current theme configuration */
201 TRACE("Loading theme config\n");
202 buffsize = sizeof(tmp);
203 if(!RegQueryValueExW(hKey, szThemeActive, NULL, NULL, (LPBYTE)tmp, &buffsize)) {
204 bThemeActive = (tmp[0] != '0');
205 }
206 else {
208 TRACE("Failed to get ThemeActive: %d\n", GetLastError());
209 }
210 buffsize = sizeof(szCurrentColor);
211 if(RegQueryValueExW(hKey, szColorName, NULL, NULL, (LPBYTE)szCurrentColor, &buffsize))
212 szCurrentColor[0] = '\0';
213 buffsize = sizeof(szCurrentSize);
214 if(RegQueryValueExW(hKey, szSizeName, NULL, NULL, (LPBYTE)szCurrentSize, &buffsize))
215 szCurrentSize[0] = '\0';
216 if (query_reg_path (hKey, szDllName, szCurrentTheme))
217 szCurrentTheme[0] = '\0';
219 }
220 else
221 TRACE("Failed to open theme registry key\n");
222 }
223 else
224 {
226 }
227
228 if(bThemeActive)
229 {
230 if( bIsThemeActive(szCurrentTheme, szCurrentColor, szCurrentSize) )
231 {
232 TRACE("Tried to load active theme again\n");
233 return;
234 }
235
236 /* Make sure the theme requested is actually valid */
237 hr = MSSTYLES_OpenThemeFile(szCurrentTheme,
238 szCurrentColor[0]?szCurrentColor:NULL,
239 szCurrentSize[0]?szCurrentSize:NULL,
240 &pt);
241 if(FAILED(hr)) {
243 }
244 else {
245 TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme),
246 debugstr_w(szCurrentColor), debugstr_w(szCurrentSize));
247
250 }
251 }
252 if(!bThemeActive) {
254 TRACE("Theming not active\n");
255 }
256}
257
258/***********************************************************************/
259
260static const char * const SysColorsNames[] =
261{
262 "Scrollbar", /* COLOR_SCROLLBAR */
263 "Background", /* COLOR_BACKGROUND */
264 "ActiveTitle", /* COLOR_ACTIVECAPTION */
265 "InactiveTitle", /* COLOR_INACTIVECAPTION */
266 "Menu", /* COLOR_MENU */
267 "Window", /* COLOR_WINDOW */
268 "WindowFrame", /* COLOR_WINDOWFRAME */
269 "MenuText", /* COLOR_MENUTEXT */
270 "WindowText", /* COLOR_WINDOWTEXT */
271 "TitleText", /* COLOR_CAPTIONTEXT */
272 "ActiveBorder", /* COLOR_ACTIVEBORDER */
273 "InactiveBorder", /* COLOR_INACTIVEBORDER */
274 "AppWorkSpace", /* COLOR_APPWORKSPACE */
275 "Hilight", /* COLOR_HIGHLIGHT */
276 "HilightText", /* COLOR_HIGHLIGHTTEXT */
277 "ButtonFace", /* COLOR_BTNFACE */
278 "ButtonShadow", /* COLOR_BTNSHADOW */
279 "GrayText", /* COLOR_GRAYTEXT */
280 "ButtonText", /* COLOR_BTNTEXT */
281 "InactiveTitleText", /* COLOR_INACTIVECAPTIONTEXT */
282 "ButtonHilight", /* COLOR_BTNHIGHLIGHT */
283 "ButtonDkShadow", /* COLOR_3DDKSHADOW */
284 "ButtonLight", /* COLOR_3DLIGHT */
285 "InfoText", /* COLOR_INFOTEXT */
286 "InfoWindow", /* COLOR_INFOBK */
287 "ButtonAlternateFace", /* COLOR_ALTERNATEBTNFACE */
288 "HotTrackingColor", /* COLOR_HOTLIGHT */
289 "GradientActiveTitle", /* COLOR_GRADIENTACTIVECAPTION */
290 "GradientInactiveTitle", /* COLOR_GRADIENTINACTIVECAPTION */
291 "MenuHilight", /* COLOR_MENUHILIGHT */
292 "MenuBar", /* COLOR_MENUBAR */
293};
294static const WCHAR strColorKey[] =
295 { 'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
296 'C','o','l','o','r','s',0 };
297static const WCHAR keyFlatMenus[] = { 'F','l','a','t','M','e','n','u', 0};
298static const WCHAR keyGradientCaption[] = { 'G','r','a','d','i','e','n','t',
299 'C','a','p','t','i','o','n', 0 };
300static const WCHAR keyNonClientMetrics[] = { 'N','o','n','C','l','i','e','n','t',
301 'M','e','t','r','i','c','s',0 };
302static const WCHAR keyIconTitleFont[] = { 'I','c','o','n','T','i','t','l','e',
303 'F','o','n','t',0 };
304
305static const struct BackupSysParam
306{
309} backupSysParams[] =
310{
311 {SPI_GETFLATMENU, SPI_SETFLATMENU, keyFlatMenus},
312 {SPI_GETGRADIENTCAPTIONS, SPI_SETGRADIENTCAPTIONS, keyGradientCaption},
313 {-1, -1, 0}
315
316#define NUM_SYS_COLORS (COLOR_MENUBAR+1)
317
318static void save_sys_colors (HKEY baseKey)
319{
320 char colorStr[13];
321 HKEY hKey;
322 int i;
323
324 if (RegCreateKeyExW( baseKey, strColorKey,
325 0, 0, 0, KEY_ALL_ACCESS,
326 0, &hKey, 0 ) == ERROR_SUCCESS)
327 {
328 for (i = 0; i < NUM_SYS_COLORS; i++)
329 {
330 COLORREF col = GetSysColor (i);
331
332 sprintf (colorStr, "%d %d %d",
333 GetRValue (col), GetGValue (col), GetBValue (col));
334
336 (BYTE*)colorStr, strlen (colorStr)+1);
337 }
339 }
340}
341
342/* Before activating a theme, query current system colors, certain settings
343 * and backup them in the registry, so they can be restored when the theme
344 * is deactivated */
346{
347 HKEY hKey;
348 const struct BackupSysParam* bsp = backupSysParams;
349
351 0, 0, 0, KEY_ALL_ACCESS,
352 0, &hKey, 0) == ERROR_SUCCESS)
353 {
354 NONCLIENTMETRICSW ncm;
355 LOGFONTW iconTitleFont;
356
357 /* back up colors */
359
360 /* back up "other" settings */
361 while (bsp->spiGet >= 0)
362 {
363 DWORD value;
364
365 SystemParametersInfoW (bsp->spiGet, 0, &value, 0);
367 (LPBYTE)&value, sizeof (value));
368
369 bsp++;
370 }
371
372 /* back up non-client metrics */
373 memset (&ncm, 0, sizeof (ncm));
374 ncm.cbSize = sizeof (ncm);
375 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof (ncm), &ncm, 0);
377 sizeof (ncm));
378 memset (&iconTitleFont, 0, sizeof (iconTitleFont));
379 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof (iconTitleFont),
380 &iconTitleFont, 0);
382 (LPBYTE)&iconTitleFont, sizeof (iconTitleFont));
383
385 }
386}
387
388/* Read back old settings after a theme was deactivated */
390{
391 HKEY hKey;
392 const struct BackupSysParam* bsp = backupSysParams;
393
396 {
397 HKEY colorKey;
398
399 /* read backed-up colors */
401 0, KEY_QUERY_VALUE, &colorKey) == ERROR_SUCCESS)
402 {
403 int i;
404 COLORREF sysCols[NUM_SYS_COLORS];
405 int sysColsIndices[NUM_SYS_COLORS];
406 int sysColCount = 0;
407
408 for (i = 0; i < NUM_SYS_COLORS; i++)
409 {
410 DWORD type;
411 char colorStr[13];
412 DWORD count = sizeof(colorStr);
413
414 if (RegQueryValueExA (colorKey, SysColorsNames[i], 0,
415 &type, (LPBYTE) colorStr, &count) == ERROR_SUCCESS)
416 {
417 int r, g, b;
418 if (sscanf (colorStr, "%d %d %d", &r, &g, &b) == 3)
419 {
420 sysColsIndices[sysColCount] = i;
421 sysCols[sysColCount] = RGB(r, g, b);
422 sysColCount++;
423 }
424 }
425 }
426 RegCloseKey (colorKey);
427
428 SetSysColors (sysColCount, sysColsIndices, sysCols);
429 }
430
431 /* read backed-up other settings */
432 while (bsp->spiGet >= 0)
433 {
434 DWORD value;
435 DWORD count = sizeof(value);
436 DWORD type;
437
438 if (RegQueryValueExW (hKey, bsp->keyName, 0,
440 {
442 }
443
444 bsp++;
445 }
446
447 /* read backed-up non-client metrics */
448 {
449 NONCLIENTMETRICSW ncm;
450 LOGFONTW iconTitleFont;
451 DWORD count = sizeof(ncm);
452 DWORD type;
453
455 &type, (LPBYTE)&ncm, &count) == ERROR_SUCCESS)
456 {
457 SystemParametersInfoW (SPI_SETNONCLIENTMETRICS,
459 }
460
461 count = sizeof(iconTitleFont);
462
464 &type, (LPBYTE)&iconTitleFont, &count) == ERROR_SUCCESS)
465 {
467 count, &iconTitleFont, SPIF_UPDATEINIFILE);
468 }
469 }
470
472 }
473}
474
475/* Make system settings persistent, so they're in effect even w/o uxtheme
476 * loaded.
477 * For efficiency reasons, only the last SystemParametersInfoW sets
478 * SPIF_SENDCHANGE */
480{
481 const struct BackupSysParam* bsp = backupSysParams;
482 NONCLIENTMETRICSW ncm;
483 LOGFONTW iconTitleFont;
484
486
487 while (bsp->spiGet >= 0)
488 {
489 DWORD value;
490
491 SystemParametersInfoW (bsp->spiGet, 0, &value, 0);
493 bsp++;
494 }
495
496 memset (&ncm, 0, sizeof (ncm));
497 ncm.cbSize = sizeof (ncm);
498 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof (ncm), &ncm, 0);
499 SystemParametersInfoW (SPI_SETNONCLIENTMETRICS, sizeof (ncm), &ncm,
501
502 memset (&iconTitleFont, 0, sizeof (iconTitleFont));
503 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof (iconTitleFont),
504 &iconTitleFont, 0);
505 SystemParametersInfoW (SPI_SETICONTITLELOGFONT, sizeof (iconTitleFont),
506 &iconTitleFont, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
507}
508
509/***********************************************************************
510 * UXTHEME_ApplyTheme
511 *
512 * Change the current active theme
513 */
515{
516 HKEY hKey;
517 WCHAR tmp[2];
518 HRESULT hr;
519
520 TRACE("UXTHEME_ApplyTheme\n");
521
522 if (tf && !g_ActiveThemeFile)
523 {
525 }
526
528 if (FAILED(hr))
529 return hr;
530
531 if (!tf)
532 {
534 }
535
536 TRACE("Writing theme config to registry\n");
538 tmp[0] = g_ActiveThemeFile ? '1' : '0';
539 tmp[1] = '\0';
540 RegSetValueExW(hKey, szThemeActive, 0, REG_SZ, (const BYTE*)tmp, sizeof(WCHAR)*2);
541 if (g_ActiveThemeFile) {
542 RegSetValueExW(hKey, szColorName, 0, REG_SZ, (const BYTE*)tf->pszSelectedColor,
543 (lstrlenW(tf->pszSelectedColor)+1)*sizeof(WCHAR));
544 RegSetValueExW(hKey, szSizeName, 0, REG_SZ, (const BYTE*)tf->pszSelectedSize,
545 (lstrlenW(tf->pszSelectedSize)+1)*sizeof(WCHAR));
546 RegSetValueExW(hKey, szDllName, 0, REG_SZ, (const BYTE*)tf->szThemeFile,
547 (lstrlenW(tf->szThemeFile)+1)*sizeof(WCHAR));
548 }
549 else {
553
554 }
556 }
557 else
558 TRACE("Failed to open theme registry key\n");
559
561
562 return hr;
563}
564
565/***********************************************************************
566 * UXTHEME_InitSystem
567 */
569{
570 static const WCHAR szWindowTheme[] = {
571 'u','x','_','t','h','e','m','e','\0'
572 };
573 static const WCHAR szSubAppName[] = {
574 'u','x','_','s','u','b','a','p','p','\0'
575 };
576 static const WCHAR szSubIdList[] = {
577 'u','x','_','s','u','b','i','d','l','s','t','\0'
578 };
579 static const WCHAR szDialogThemeEnabled[] = {
580 'u','x','_','d','i','a','l','o','g','t','h','e','m','e','\0'
581 };
582
583 hDllInst = hInst;
584
585 atWindowTheme = GlobalAddAtomW(szWindowTheme);
586 atSubAppName = GlobalAddAtomW(szSubAppName);
587 atSubIdList = GlobalAddAtomW(szSubIdList);
588 atDialogThemeEnabled = GlobalAddAtomW(szDialogThemeEnabled);
589 atWndContext = GlobalAddAtomW(L"ux_WndContext");
590
592 g_cHandles = 0;
593
595}
596
597/***********************************************************************
598 * UXTHEME_UnInitSystem
599 */
601{
603
606}
607
608/***********************************************************************
609 * IsAppThemed (UXTHEME.@)
610 */
612{
613 TRACE("\n");
615 return (g_ActiveThemeFile != NULL);
616}
617
618/***********************************************************************
619 * IsThemeActive (UXTHEME.@)
620 */
622{
623 BOOL bActive;
625 HKEY hKey;
626 WCHAR tmp[10];
627 DWORD buffsize;
628
629 TRACE("IsThemeActive\n");
631
633 return TRUE;
634
636 return FALSE;
637
638 bActive = FALSE;
640 if (Result == ERROR_SUCCESS)
641 {
642 buffsize = sizeof(tmp);
643 if (!RegQueryValueExW(hKey, szThemeActive, NULL, NULL, (LPBYTE)tmp, &buffsize))
644 bActive = (tmp[0] != '0');
646 }
647
648 return bActive;
649}
650
651/***********************************************************************
652 * EnableTheming (UXTHEME.@)
653 *
654 * NOTES
655 * This is a global and persistent change
656 */
658{
659 HKEY hKey;
660 WCHAR szEnabled[] = {'0','\0'};
661
662 TRACE("(%d)\n", fEnable);
663
664 if (fEnable != (g_ActiveThemeFile != NULL)) {
665 if(fEnable)
667 else
670
671 if (fEnable) szEnabled[0] = '1';
673 RegSetValueExW(hKey, szThemeActive, 0, REG_SZ, (LPBYTE)szEnabled, sizeof(WCHAR));
675 }
677 }
678 return S_OK;
679}
680
681/***********************************************************************
682 * UXTHEME_SetWindowProperty
683 *
684 * I'm using atoms as there may be large numbers of duplicated strings
685 * and they do the work of keeping memory down as a cause of that quite nicely
686 */
688{
689 ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
690 if(oldValue)
691 {
692 DeleteAtom(oldValue);
693 }
694
695 if(pszValue)
696 {
697 ATOM atValue;
698
699 /* A string with zero lenght is not acceptatble in AddAtomW but we want to support
700 users passing an empty string meaning they want no theme for the specified window */
701 if(!pszValue[0])
702 pszValue = L"0";
703
704 atValue = AddAtomW(pszValue);
705 if (!atValue)
706 {
707 ERR("AddAtomW for %S failed with last error %d!\n", pszValue, GetLastError());
709 }
710
711 if (!SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp), (LPWSTR)MAKEINTATOM(atValue)))
712 {
713 ERR("SetPropW for atom %d failed with last error %d\n", aProp, GetLastError());
714 if(atValue) DeleteAtom(atValue);
716 }
717 }
718 return S_OK;
719}
720
721static LPWSTR UXTHEME_GetWindowProperty(HWND hwnd, ATOM aProp, LPWSTR pszBuffer, int dwLen)
722{
723 ATOM atValue = (ATOM)(size_t)GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
724 if(atValue) {
725 if(GetAtomNameW(atValue, pszBuffer, dwLen))
726 return pszBuffer;
727 TRACE("property defined, but unable to get value\n");
728 }
729 return NULL;
730}
731
733{
734 PUXTHEME_HANDLE pHandle;
735
736 if (!g_bThemeHooksActive || !hTheme || hTheme == INVALID_HANDLE_VALUE)
737 return NULL;
738
740 {
741 ERR("Invalid handle 0x%x!\n", hTheme);
742 return NULL;
743 }
744
745 pHandle = hTheme;
746 return pHandle->pClass;
747}
748
749static HTHEME WINAPI
751{
752 WCHAR szAppBuff[256];
753 WCHAR szClassBuff[256];
754 LPCWSTR pszAppName;
755 LPCWSTR pszUseClassList;
756 HTHEME hTheme = NULL;
757 TRACE("(%p,%s, %x)\n", hwnd, debugstr_w(pszClassList), flags);
758
759 if(!pszClassList)
760 {
762 return NULL;
763 }
764
765 if ((flags & OTD_NONCLIENT) && !(dwThemeAppProperties & STAP_ALLOW_NONCLIENT))
766 {
768 return NULL;
769 }
770
771 if (!(flags & OTD_NONCLIENT) && !(dwThemeAppProperties & STAP_ALLOW_CONTROLS))
772 {
774 return NULL;
775 }
776
777 if (ThemeFile)
778 {
779 pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, sizeof(szAppBuff)/sizeof(szAppBuff[0]));
780 /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */
781 pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, sizeof(szClassBuff)/sizeof(szClassBuff[0]));
782 if(!pszUseClassList)
783 pszUseClassList = pszClassList;
784
785 if (pszUseClassList)
786 {
787 PTHEME_CLASS pClass;
788 PUXTHEME_HANDLE pHandle;
789
790 if (!ThemeFile->classes)
791 MSSTYLES_ParseThemeIni(ThemeFile);
792 pClass = MSSTYLES_OpenThemeClass(ThemeFile, pszAppName, pszUseClassList);
793
794 if (pClass)
795 {
797 if (pHandle)
798 {
799 g_cHandles++;
800 TRACE("Created handle 0x%x for class 0x%x, app %S, class %S. Count: %d\n", pHandle, pClass, pszAppName, pszUseClassList, g_cHandles);
801 pHandle->pClass = pClass;
802 pHandle->Handle.Flags = RTL_HANDLE_VALID;
803 hTheme = pHandle;
804 }
805 else
806 {
808 }
809 }
810 }
811 }
812
813 if(IsWindow(hwnd))
814 {
815 if ((flags & OTD_NONCLIENT) == 0)
816 {
818 }
819 }
820 else
821 {
823 }
824
826
827 TRACE(" = %p\n", hTheme);
828 return hTheme;
829}
830
831/***********************************************************************
832 * OpenThemeDataEx (UXTHEME.61)
833 */
835{
836 return OpenThemeDataInternal(g_ActiveThemeFile, hwnd, pszClassList, flags);
837}
838
839/***********************************************************************
840 * OpenThemeDataFromFile (UXTHEME.16)
841 */
843{
844 return OpenThemeDataInternal((PTHEME_FILE)hThemeFile, hwnd, pszClassList, flags);
845}
846
847/***********************************************************************
848 * OpenThemeData (UXTHEME.@)
849 */
851{
852 return OpenThemeDataInternal(g_ActiveThemeFile, hwnd, classlist, 0);
853}
854
855/***********************************************************************
856 * GetWindowTheme (UXTHEME.@)
857 *
858 * Retrieve the last theme opened for a window.
859 *
860 * PARAMS
861 * hwnd [I] window to retrieve the theme for
862 *
863 * RETURNS
864 * The most recent theme.
865 */
867{
868 TRACE("(%p)\n", hwnd);
869
870 if(!IsWindow(hwnd))
871 {
873 return NULL;
874 }
875
877}
878
879/***********************************************************************
880 * SetWindowTheme (UXTHEME.@)
881 *
882 * Persistent through the life of the window, even after themes change
883 */
885 LPCWSTR pszSubIdList)
886{
887 HRESULT hr;
888 TRACE("(%p,%s,%s)\n", hwnd, debugstr_w(pszSubAppName),
889 debugstr_w(pszSubIdList));
890
891 if(!IsWindow(hwnd))
892 return E_HANDLE;
893
895 if (!SUCCEEDED(hr))
896 return hr;
897
899 if (!SUCCEEDED(hr))
900 return hr;
901
903 return hr;
904}
905
906/***********************************************************************
907 * GetCurrentThemeName (UXTHEME.@)
908 */
909HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars,
910 LPWSTR pszColorBuff, int cchMaxColorChars,
911 LPWSTR pszSizeBuff, int cchMaxSizeChars)
912{
913 int cchar;
914
917
918 if (pszThemeFileName && dwMaxNameChars)
919 {
921 if(cchar > dwMaxNameChars)
923 lstrcpynW(pszThemeFileName, g_ActiveThemeFile->szThemeFile, cchar);
924 }
925
926 if (pszColorBuff && cchMaxColorChars)
927 {
929 if(cchar > cchMaxColorChars)
931 lstrcpynW(pszColorBuff, g_ActiveThemeFile->pszSelectedColor, cchar);
932 }
933
934 if (pszSizeBuff && cchMaxSizeChars)
935 {
937 if(cchar > cchMaxSizeChars)
939 lstrcpynW(pszSizeBuff, g_ActiveThemeFile->pszSelectedSize, cchar);
940 }
941
942 return S_OK;
943}
944
945/***********************************************************************
946 * GetThemeAppProperties (UXTHEME.@)
947 */
949{
951}
952
953/***********************************************************************
954 * SetThemeAppProperties (UXTHEME.@)
955 */
957{
958 TRACE("(0x%08x)\n", dwFlags);
960}
961
962/***********************************************************************
963 * CloseThemeData (UXTHEME.@)
964 */
966{
967 PUXTHEME_HANDLE pHandle = hTheme;
968 HRESULT hr;
969
970 TRACE("(%p)\n", hTheme);
971
973 return E_HANDLE;
974
976 if (SUCCEEDED(hr))
977 {
979 g_cHandles--;
980 TRACE("Destroying handle 0x%x for class 0x%x. Count: %d\n", pHandle, pHandle->pClass, g_cHandles);
981 }
982 return hr;
983}
984
985/***********************************************************************
986 * HitTestThemeBackground (UXTHEME.@)
987 */
989 int iStateId, DWORD dwOptions,
990 const RECT *pRect, HRGN hrgn,
991 POINT ptTest, WORD *pwHitTestCode)
992{
993 FIXME("%d %d 0x%08x: stub\n", iPartId, iStateId, dwOptions);
994 if (!ValidateHandle(hTheme))
995 return E_HANDLE;
996 return E_NOTIMPL;
997}
998
999/***********************************************************************
1000 * IsThemePartDefined (UXTHEME.@)
1001 */
1002BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId)
1003{
1004 PTHEME_CLASS pClass;
1005
1006 TRACE("(%p,%d,%d)\n", hTheme, iPartId, iStateId);
1007
1008 pClass = ValidateHandle(hTheme);
1009 if (!pClass)
1010 {
1012 return FALSE;
1013 }
1014 if(MSSTYLES_FindPartState(pClass, iPartId, iStateId, NULL))
1015 return TRUE;
1016 return FALSE;
1017}
1018
1019/***********************************************************************
1020 * GetThemeDocumentationProperty (UXTHEME.@)
1021 *
1022 * Try and retrieve the documentation property from string resources
1023 * if that fails, get it from the [documentation] section of themes.ini
1024 */
1026 LPCWSTR pszPropertyName,
1027 LPWSTR pszValueBuff,
1028 int cchMaxValChars)
1029{
1030 const WORD wDocToRes[] = {
1031 TMT_DISPLAYNAME,5000,
1032 TMT_TOOLTIP,5001,
1033 TMT_COMPANY,5002,
1034 TMT_AUTHOR,5003,
1035 TMT_COPYRIGHT,5004,
1036 TMT_URL,5005,
1037 TMT_VERSION,5006,
1038 TMT_DESCRIPTION,5007
1039 };
1040
1042 HRESULT hr;
1043 unsigned int i;
1044 int iDocId;
1045 TRACE("(%s,%s,%p,%d)\n", debugstr_w(pszThemeName), debugstr_w(pszPropertyName),
1046 pszValueBuff, cchMaxValChars);
1047
1049 return E_FAIL;
1050
1051 hr = MSSTYLES_OpenThemeFile(pszThemeName, NULL, NULL, &pt);
1052 if(FAILED(hr)) return hr;
1053
1054 /* Try to load from string resources */
1056 if(MSSTYLES_LookupProperty(pszPropertyName, NULL, &iDocId)) {
1057 for(i=0; i<sizeof(wDocToRes)/sizeof(wDocToRes[0]); i+=2) {
1058 if(wDocToRes[i] == iDocId) {
1059 if(LoadStringW(pt->hTheme, wDocToRes[i+1], pszValueBuff, cchMaxValChars)) {
1060 hr = S_OK;
1061 break;
1062 }
1063 }
1064 }
1065 }
1066 /* If loading from string resource failed, try getting it from the theme.ini */
1067 if(FAILED(hr)) {
1070 LPCWSTR lpValue;
1071 DWORD dwLen;
1072 if(UXINI_FindValue(uf, pszPropertyName, &lpValue, &dwLen)) {
1073 lstrcpynW(pszValueBuff, lpValue, min(dwLen+1,cchMaxValChars));
1074 hr = S_OK;
1075 }
1076 }
1077 UXINI_CloseINI(uf);
1078 }
1079
1081 return hr;
1082}
1083
1084/**********************************************************************
1085 * Undocumented functions
1086 */
1087
1088/**********************************************************************
1089 * QueryThemeServices (UXTHEME.1)
1090 *
1091 * RETURNS
1092 * some kind of status flag
1093 */
1095{
1096 FIXME("stub\n");
1097 return 3; /* This is what is returned under XP in most cases */
1098}
1099
1100
1101/**********************************************************************
1102 * OpenThemeFile (UXTHEME.2)
1103 *
1104 * Opens a theme file, which can be used to change the current theme, etc
1105 *
1106 * PARAMS
1107 * pszThemeFileName Path to a msstyles theme file
1108 * pszColorName Color defined in the theme, eg. NormalColor
1109 * pszSizeName Size defined in the theme, eg. NormalSize
1110 * hThemeFile Handle to theme file
1111 *
1112 * RETURNS
1113 * Success: S_OK
1114 * Failure: HRESULT error-code
1115 */
1116HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName,
1117 LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile,
1118 DWORD unknown)
1119{
1120 TRACE("(%s,%s,%s,%p,%d)\n", debugstr_w(pszThemeFileName),
1121 debugstr_w(pszColorName), debugstr_w(pszSizeName),
1122 hThemeFile, unknown);
1123
1125 return E_FAIL;
1126
1127 return MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, (PTHEME_FILE*)hThemeFile);
1128}
1129
1130/**********************************************************************
1131 * CloseThemeFile (UXTHEME.3)
1132 *
1133 * Releases theme file handle returned by OpenThemeFile
1134 *
1135 * PARAMS
1136 * hThemeFile Handle to theme file
1137 *
1138 * RETURNS
1139 * Success: S_OK
1140 * Failure: HRESULT error-code
1141 */
1143{
1144 TRACE("(%p)\n", hThemeFile);
1145 MSSTYLES_CloseThemeFile(hThemeFile);
1146 return S_OK;
1147}
1148
1149/**********************************************************************
1150 * ApplyTheme (UXTHEME.4)
1151 *
1152 * Set a theme file to be the currently active theme
1153 *
1154 * PARAMS
1155 * hThemeFile Handle to theme file
1156 * unknown See notes
1157 * hWnd Window requesting the theme change
1158 *
1159 * RETURNS
1160 * Success: S_OK
1161 * Failure: HRESULT error-code
1162 *
1163 * NOTES
1164 * I'm not sure what the second parameter is (the datatype is likely wrong), other then this:
1165 * Under XP if I pass
1166 * char b[] = "";
1167 * the theme is applied with the screen redrawing really badly (flickers)
1168 * char b[] = "\0"; where \0 can be one or more of any character, makes no difference
1169 * the theme is applied smoothly (screen does not flicker)
1170 * char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference
1171 * the function fails returning invalid parameter... very strange
1172 */
1174{
1175 HRESULT hr;
1176 TRACE("(%p,%s,%p)\n", hThemeFile, unknown, hWnd);
1177 hr = UXTHEME_ApplyTheme(hThemeFile);
1179 return hr;
1180}
1181
1182/**********************************************************************
1183 * GetThemeDefaults (UXTHEME.7)
1184 *
1185 * Get the default color & size for a theme
1186 *
1187 * PARAMS
1188 * pszThemeFileName Path to a msstyles theme file
1189 * pszColorName Buffer to receive the default color name
1190 * dwColorNameLen Length, in characters, of color name buffer
1191 * pszSizeName Buffer to receive the default size name
1192 * dwSizeNameLen Length, in characters, of size name buffer
1193 *
1194 * RETURNS
1195 * Success: S_OK
1196 * Failure: HRESULT error-code
1197 */
1198HRESULT WINAPI GetThemeDefaults(LPCWSTR pszThemeFileName, LPWSTR pszColorName,
1199 DWORD dwColorNameLen, LPWSTR pszSizeName,
1200 DWORD dwSizeNameLen)
1201{
1203 HRESULT hr;
1204 TRACE("(%s,%p,%d,%p,%d)\n", debugstr_w(pszThemeFileName),
1205 pszColorName, dwColorNameLen,
1206 pszSizeName, dwSizeNameLen);
1207
1209 return E_FAIL;
1210
1211 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
1212 if(FAILED(hr)) return hr;
1213
1214 lstrcpynW(pszColorName, pt->pszSelectedColor, dwColorNameLen);
1215 lstrcpynW(pszSizeName, pt->pszSelectedSize, dwSizeNameLen);
1216
1218 return S_OK;
1219}
1220
1221/**********************************************************************
1222 * EnumThemes (UXTHEME.8)
1223 *
1224 * Enumerate available themes, calls specified EnumThemeProc for each
1225 * theme found. Passes lpData through to callback function.
1226 *
1227 * PARAMS
1228 * pszThemePath Path containing themes
1229 * callback Called for each theme found in path
1230 * lpData Passed through to callback
1231 *
1232 * RETURNS
1233 * Success: S_OK
1234 * Failure: HRESULT error-code
1235 */
1237 LPVOID lpData)
1238{
1239 WCHAR szDir[MAX_PATH];
1241 static const WCHAR szStar[] = {'*','.','*','\0'};
1242 static const WCHAR szFormat[] = {'%','s','%','s','\\','%','s','.','m','s','s','t','y','l','e','s','\0'};
1243 static const WCHAR szDisplayName[] = {'d','i','s','p','l','a','y','n','a','m','e','\0'};
1244 static const WCHAR szTooltip[] = {'t','o','o','l','t','i','p','\0'};
1245 WCHAR szName[60];
1246 WCHAR szTip[60];
1247 HANDLE hFind;
1248 WIN32_FIND_DATAW wfd;
1249 HRESULT hr;
1250 size_t pathLen;
1251
1252 TRACE("(%s,%p,%p)\n", debugstr_w(pszThemePath), callback, lpData);
1253
1254 if(!pszThemePath || !callback)
1255 return E_POINTER;
1256
1257 lstrcpyW(szDir, pszThemePath);
1258 pathLen = lstrlenW (szDir);
1259 if ((pathLen > 0) && (pathLen < MAX_PATH-1) && (szDir[pathLen - 1] != '\\'))
1260 {
1261 szDir[pathLen] = '\\';
1262 szDir[pathLen+1] = 0;
1263 }
1264
1265 lstrcpyW(szPath, szDir);
1266 lstrcatW(szPath, szStar);
1267 TRACE("searching %s\n", debugstr_w(szPath));
1268
1269 hFind = FindFirstFileW(szPath, &wfd);
1270 if(hFind != INVALID_HANDLE_VALUE) {
1271 do {
1272 if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
1273 && !(wfd.cFileName[0] == '.' && ((wfd.cFileName[1] == '.' && wfd.cFileName[2] == 0) || wfd.cFileName[1] == 0))) {
1274 wsprintfW(szPath, szFormat, szDir, wfd.cFileName, wfd.cFileName);
1275
1276 hr = GetThemeDocumentationProperty(szPath, szDisplayName, szName, sizeof(szName)/sizeof(szName[0]));
1277 if(FAILED(hr))
1278 {
1279 ERR("Failed to get theme name from %S\n", szPath);
1280 continue;
1281 }
1282
1283 hr = GetThemeDocumentationProperty(szPath, szTooltip, szTip, sizeof(szTip)/sizeof(szTip[0]));
1284 if (FAILED(hr))
1285 szTip[0] = 0;
1286
1287 TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath), debugstr_w(szName), debugstr_w(szTip), lpData);
1288 if(!callback(NULL, szPath, szName, szTip, NULL, lpData)) {
1289 TRACE("callback ended enum\n");
1290 break;
1291 }
1292 }
1293 } while(FindNextFileW(hFind, &wfd));
1294 FindClose(hFind);
1295 }
1296 return S_OK;
1297}
1298
1299
1300/**********************************************************************
1301 * EnumThemeColors (UXTHEME.9)
1302 *
1303 * Enumerate theme colors available with a particular size
1304 *
1305 * PARAMS
1306 * pszThemeFileName Path to a msstyles theme file
1307 * pszSizeName Theme size to enumerate available colors
1308 * If NULL the default theme size is used
1309 * dwColorNum Color index to retrieve, increment from 0
1310 * pszColorNames Output color names
1311 *
1312 * RETURNS
1313 * S_OK on success
1314 * E_PROP_ID_UNSUPPORTED when dwColorName does not refer to a color
1315 * or when pszSizeName does not refer to a valid size
1316 *
1317 * NOTES
1318 * XP fails with E_POINTER when pszColorNames points to a buffer smaller than
1319 * sizeof(THEMENAMES).
1320 *
1321 * Not very efficient that I'm opening & validating the theme every call, but
1322 * this is undocumented and almost never called..
1323 * (and this is how windows works too)
1324 */
1325HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName,
1326 DWORD dwColorNum, PTHEMENAMES pszColorNames)
1327{
1329 HRESULT hr;
1330 LPWSTR tmp;
1331 UINT resourceId = dwColorNum + 1000;
1332 TRACE("(%s,%s,%d)\n", debugstr_w(pszThemeFileName),
1333 debugstr_w(pszSizeName), dwColorNum);
1334
1336 return E_FAIL;
1337
1338 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, pszSizeName, &pt);
1339 if(FAILED(hr)) return hr;
1340
1341 tmp = pt->pszAvailColors;
1342 while(dwColorNum && *tmp) {
1343 dwColorNum--;
1344 tmp += lstrlenW(tmp)+1;
1345 }
1346 if(!dwColorNum && *tmp) {
1347 TRACE("%s\n", debugstr_w(tmp));
1348 lstrcpyW(pszColorNames->szName, tmp);
1349 LoadStringW (pt->hTheme, resourceId,
1350 pszColorNames->szDisplayName,
1351 sizeof (pszColorNames->szDisplayName) / sizeof (WCHAR));
1352 LoadStringW (pt->hTheme, resourceId+1000,
1353 pszColorNames->szTooltip,
1354 sizeof (pszColorNames->szTooltip) / sizeof (WCHAR));
1355 }
1356 else
1358
1360 return hr;
1361}
1362
1363/**********************************************************************
1364 * EnumThemeSizes (UXTHEME.10)
1365 *
1366 * Enumerate theme colors available with a particular size
1367 *
1368 * PARAMS
1369 * pszThemeFileName Path to a msstyles theme file
1370 * pszColorName Theme color to enumerate available sizes
1371 * If NULL the default theme color is used
1372 * dwSizeNum Size index to retrieve, increment from 0
1373 * pszSizeNames Output size names
1374 *
1375 * RETURNS
1376 * S_OK on success
1377 * E_PROP_ID_UNSUPPORTED when dwSizeName does not refer to a size
1378 * or when pszColorName does not refer to a valid color
1379 *
1380 * NOTES
1381 * XP fails with E_POINTER when pszSizeNames points to a buffer smaller than
1382 * sizeof(THEMENAMES).
1383 *
1384 * Not very efficient that I'm opening & validating the theme every call, but
1385 * this is undocumented and almost never called..
1386 * (and this is how windows works too)
1387 */
1388HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName,
1389 DWORD dwSizeNum, PTHEMENAMES pszSizeNames)
1390{
1392 HRESULT hr;
1393 LPWSTR tmp;
1394 UINT resourceId = dwSizeNum + 3000;
1395 TRACE("(%s,%s,%d)\n", debugstr_w(pszThemeFileName),
1396 debugstr_w(pszColorName), dwSizeNum);
1397
1399 return E_FAIL;
1400
1401 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, NULL, &pt);
1402 if(FAILED(hr)) return hr;
1403
1404 tmp = pt->pszAvailSizes;
1405 while(dwSizeNum && *tmp) {
1406 dwSizeNum--;
1407 tmp += lstrlenW(tmp)+1;
1408 }
1409 if(!dwSizeNum && *tmp) {
1410 TRACE("%s\n", debugstr_w(tmp));
1411 lstrcpyW(pszSizeNames->szName, tmp);
1412 LoadStringW (pt->hTheme, resourceId,
1413 pszSizeNames->szDisplayName,
1414 sizeof (pszSizeNames->szDisplayName) / sizeof (WCHAR));
1415 LoadStringW (pt->hTheme, resourceId+1000,
1416 pszSizeNames->szTooltip,
1417 sizeof (pszSizeNames->szTooltip) / sizeof (WCHAR));
1418 }
1419 else
1421
1423 return hr;
1424}
1425
1426/**********************************************************************
1427 * ParseThemeIniFile (UXTHEME.11)
1428 *
1429 * Enumerate data in a theme INI file.
1430 *
1431 * PARAMS
1432 * pszIniFileName Path to a theme ini file
1433 * pszUnknown Cannot be NULL, L"" is valid
1434 * callback Called for each found entry
1435 * lpData Passed through to callback
1436 *
1437 * RETURNS
1438 * S_OK on success
1439 * 0x800706488 (Unknown property) when enumeration is canceled from callback
1440 *
1441 * NOTES
1442 * When pszUnknown is NULL the callback is never called, the value does not seem to serve
1443 * any other purpose
1444 */
1445HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
1447{
1448 FIXME("%s %s: stub\n", debugstr_w(pszIniFileName), debugstr_w(pszUnknown));
1449 return E_NOTIMPL;
1450}
1451
1452/**********************************************************************
1453 * CheckThemeSignature (UXTHEME.29)
1454 *
1455 * Validates the signature of a theme file
1456 *
1457 * PARAMS
1458 * pszIniFileName Path to a theme file
1459 *
1460 * RETURNS
1461 * Success: S_OK
1462 * Failure: HRESULT error-code
1463 */
1465{
1467 HRESULT hr;
1468 TRACE("(%s)\n", debugstr_w(pszThemeFileName));
1469
1471 return E_FAIL;
1472
1473 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
1474 if(FAILED(hr))
1475 return hr;
1477 return S_OK;
1478}
static HRGN hrgn
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
HWND hWnd
Definition: settings.c:17
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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 RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
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 RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
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
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define lstrcpyW
Definition: compat.h:749
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
UINT WINAPI GetAtomNameW(ATOM nAtom, LPWSTR lpBuffer, int nSize)
Definition: atom.c:589
ATOM WINAPI DeleteAtom(ATOM nAtom)
Definition: atom.c:546
ATOM WINAPI AddAtomW(LPCWSTR lpString)
Definition: atom.c:536
ATOM WINAPI GlobalAddAtomW(LPCWSTR lpString)
Definition: atom.c:444
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
HRESULT WINAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName, LPCWSTR pszPropertyName, LPWSTR pszValueBuff, int cchMaxValChars)
Definition: system.c:1025
void UXTHEME_LoadTheme(BOOL bLoad)
Definition: system.c:185
void WINAPI SetThemeAppProperties(DWORD dwFlags)
Definition: system.c:956
HRESULT WINAPI EnableTheming(BOOL fEnable)
Definition: system.c:657
static BOOL bIsThemeActive(LPCWSTR pszTheme, LPCWSTR pszColor, LPCWSTR pszSize)
Definition: system.c:147
static const WCHAR strColorKey[]
Definition: system.c:294
static const WCHAR keyIconTitleFont[]
Definition: system.c:302
DWORD gdwErrorInfoTlsIndex
Definition: system.c:27
HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown, PARSETHEMEINIFILEPROC callback, LPVOID lpData)
Definition: system.c:1445
DWORD WINAPI GetThemeAppProperties(void)
Definition: system.c:948
#define NUM_SYS_COLORS
Definition: system.c:316
static void UXTHEME_SaveSystemMetrics(void)
Definition: system.c:479
static const WCHAR szSizeName[]
Definition: system.c:41
static const WCHAR keyNonClientMetrics[]
Definition: system.c:300
static const struct BackupSysParam backupSysParams[]
static LPWSTR UXTHEME_GetWindowProperty(HWND hwnd, ATOM aProp, LPWSTR pszBuffer, int dwLen)
Definition: system.c:721
HTHEME WINAPI OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:834
static const WCHAR szThemeManager[]
Definition: system.c:33
static HTHEME WINAPI OpenThemeDataInternal(PTHEME_FILE ThemeFile, HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:750
HINSTANCE hDllInst
Definition: system.c:47
BOOL CALLBACK UXTHEME_broadcast_theme_changed(HWND hWnd, LPARAM enable)
Definition: system.c:70
static const WCHAR szDllName[]
Definition: system.c:43
int g_cHandles
Definition: system.c:59
HTHEME WINAPI OpenThemeDataFromFile(HTHEMEFILE hThemeFile, HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:842
HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList)
Definition: system.c:884
HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars, LPWSTR pszColorBuff, int cchMaxColorChars, LPWSTR pszSizeBuff, int cchMaxSizeChars)
Definition: system.c:909
RTL_HANDLE_TABLE g_UxThemeHandleTable
Definition: system.c:58
static ATOM atSubIdList
Definition: system.c:53
ATOM atWndContext
Definition: system.c:54
DWORD WINAPI QueryThemeServices(void)
Definition: system.c:1094
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:850
static HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
Definition: system.c:134
HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd)
Definition: system.c:1173
static void UXTHEME_RestoreSystemMetrics(void)
Definition: system.c:389
BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId)
Definition: system.c:1002
static const WCHAR szIniDocumentation[]
Definition: system.c:45
static HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue)
Definition: system.c:687
HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile, DWORD unknown)
Definition: system.c:1116
static BOOL CALLBACK UXTHEME_send_theme_changed(HWND hWnd, LPARAM enable)
Definition: system.c:63
HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName, DWORD dwColorNum, PTHEMENAMES pszColorNames)
Definition: system.c:1325
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:866
HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName, DWORD dwSizeNum, PTHEMENAMES pszSizeNames)
Definition: system.c:1388
static const WCHAR keyGradientCaption[]
Definition: system.c:298
HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, ENUMTHEMEPROC callback, LPVOID lpData)
Definition: system.c:1236
void UXTHEME_InitSystem(HINSTANCE hInst)
Definition: system.c:568
static const WCHAR szThemeActive[]
Definition: system.c:40
HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile)
Definition: system.c:1142
ATOM atWindowTheme
Definition: system.c:51
PTHEME_FILE g_ActiveThemeFile
Definition: system.c:56
static ATOM atSubAppName
Definition: system.c:52
static DWORD dwThemeAppProperties
Definition: system.c:50
ATOM atDialogThemeEnabled
Definition: system.c:48
static HRESULT UXTHEME_ApplyTheme(PTHEME_FILE tf)
Definition: system.c:514
static void UXTHEME_BackupSystemMetrics(void)
Definition: system.c:345
static const char *const SysColorsNames[]
Definition: system.c:260
BOOL WINAPI IsThemeActive(void)
Definition: system.c:621
HRESULT WINAPI HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, DWORD dwOptions, const RECT *pRect, HRGN hrgn, POINT ptTest, WORD *pwHitTestCode)
Definition: system.c:988
static DWORD query_reg_path(HKEY hKey, LPCWSTR lpszValue, LPVOID pvData)
Definition: system.c:86
PTHEME_CLASS ValidateHandle(HTHEME hTheme)
Definition: system.c:732
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:965
void UXTHEME_UnInitSystem(HINSTANCE hInst)
Definition: system.c:600
static const WCHAR keyFlatMenus[]
Definition: system.c:297
static void save_sys_colors(HKEY baseKey)
Definition: system.c:318
BOOL WINAPI IsAppThemed(void)
Definition: system.c:611
static const WCHAR szColorName[]
Definition: system.c:42
HRESULT WINAPI GetThemeDefaults(LPCWSTR pszThemeFileName, LPWSTR pszColorName, DWORD dwColorNameLen, LPWSTR pszSizeName, DWORD dwSizeNameLen)
Definition: system.c:1198
HRESULT WINAPI CheckThemeSignature(LPCWSTR pszThemeFileName)
Definition: system.c:1464
#define pt(x, y)
Definition: drawing.c:79
#define RGB(r, g, b)
Definition: precomp.h:71
#define GetBValue(quad)
Definition: precomp.h:75
#define GetGValue(quad)
Definition: precomp.h:74
#define GetRValue(quad)
Definition: precomp.h:73
#define UlongToPtr(u)
Definition: config.h:106
HINSTANCE hInst
Definition: dxdiag.c:13
VOID UXTHEME_DeleteParseErrorInfo(VOID)
Definition: errinfo.c:34
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
FxAutoRegKey hKey
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLbitfield flags
Definition: glext.h:7161
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean enable
Definition: glext.h:11120
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
HFONT tf
Definition: icontest.c:17
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define b
Definition: ke_i.h:79
#define debugstr_w
Definition: kernel32.h:32
#define REG_SZ
Definition: layer.c:22
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
LPCWSTR szPath
Definition: env.c:37
#define sprintf(buf, format,...)
Definition: sprintf.c:55
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static IPrintDialogCallback callback
Definition: printdlg.c:326
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define min(a, b)
Definition: monoChain.cc:55
PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId, PTHEME_CLASS *tcNext)
Definition: msstyles.c:452
PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf)
Definition: msstyles.c:236
HRESULT MSSTYLES_ReferenceTheme(PTHEME_FILE tf)
Definition: msstyles.c:224
PTHEME_CLASS MSSTYLES_OpenThemeClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWSTR pszClassList)
Definition: msstyles.c:756
void MSSTYLES_CloseThemeFile(PTHEME_FILE tf)
Definition: msstyles.c:179
HRESULT MSSTYLES_OpenThemeFile(LPCWSTR lpThemeFile, LPCWSTR pszColorName, LPCWSTR pszSizeName, PTHEME_FILE *tf)
Definition: msstyles.c:54
HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc)
Definition: msstyles.c:822
void MSSTYLES_ParseThemeIni(PTHEME_FILE tf)
Definition: msstyles.c:644
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI VOID NTAPI RtlInitializeHandleTable(_In_ ULONG TableSize, _In_ ULONG HandleSize, _In_ PRTL_HANDLE_TABLE HandleTable)
NTSYSAPI BOOLEAN NTAPI RtlFreeHandle(_In_ PRTL_HANDLE_TABLE HandleTable, _In_ PRTL_HANDLE_TABLE_ENTRY Handle)
NTSYSAPI PRTL_HANDLE_TABLE_ENTRY NTAPI RtlAllocateHandle(_In_ PRTL_HANDLE_TABLE HandleTable, _Inout_ PULONG Index)
NTSYSAPI BOOLEAN NTAPI RtlIsValidHandle(_In_ PRTL_HANDLE_TABLE HandleTable, _In_ PRTL_HANDLE_TABLE_ENTRY Handle)
#define RTL_HANDLE_VALID
Definition: rtltypes.h:376
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define L(x)
Definition: ntvdm.h:50
static const WCHAR szName[]
Definition: powrprof.c:45
static BOOL bThemeActive
Definition: scroll.c:29
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwOptions
Definition: solitaire.cpp:25
const WCHAR * keyName
Definition: system.c:308
Definition: rtltypes.h:1247
ULONG Flags
Definition: rtltypes.h:1250
WCHAR szThemeFile[MAX_PATH]
Definition: uxthemep.h:81
LPWSTR pszAvailColors
Definition: uxthemep.h:82
LPWSTR pszSelectedSize
Definition: uxthemep.h:86
PTHEME_CLASS classes
Definition: uxthemep.h:88
LPWSTR pszAvailSizes
Definition: uxthemep.h:83
LPWSTR pszSelectedColor
Definition: uxthemep.h:85
RTL_HANDLE_TABLE_ENTRY Handle
Definition: uxthemep.h:107
PTHEME_CLASS pClass
Definition: uxthemep.h:108
WCHAR szDisplayName[MAX_PATH+1]
Definition: uxundoc.h:69
WCHAR szName[MAX_PATH+1]
Definition: uxundoc.h:68
WCHAR szTooltip[MAX_PATH+1]
Definition: uxundoc.h:70
BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId)
Definition: stylemap.c:1100
#define max(a, b)
Definition: svc.c:63
BOOL g_bThemeHooksActive
Definition: themehooks.c:15
unsigned char * LPBYTE
Definition: typedefs.h:53
Definition: pdh_main.c:94
BOOL UXINI_FindSection(PUXINI_FILE uf, LPCWSTR lpName)
Definition: uxini.c:200
BOOL UXINI_FindValue(PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen)
Definition: uxini.c:280
void UXINI_CloseINI(PUXINI_FILE uf)
Definition: uxini.c:83
struct _UXTHEME_HANDLE * PUXTHEME_HANDLE
BOOL(CALLBACK * ENUMTHEMEPROC)(LPVOID lpReserved, LPCWSTR pszThemeFileName, LPCWSTR pszThemeName, LPCWSTR pszToolTip, LPVOID lpReserved2, LPVOID lpData)
Definition: uxundoc.h:37
BOOL(CALLBACK * PARSETHEMEINIFILEPROC)(DWORD dwType, LPWSTR pszParam1, LPWSTR pszParam2, LPWSTR pszParam3, DWORD dwParam, LPVOID lpData)
Definition: uxundoc.h:60
#define E_PROP_ID_UNSUPPORTED
Definition: vfwmsgs.h:173
#define TMT_COMPANY
Definition: vssym32.h:156
#define TMT_DESCRIPTION
Definition: vssym32.h:161
#define TMT_TOOLTIP
Definition: vssym32.h:155
#define TMT_URL
Definition: vssym32.h:159
#define TMT_VERSION
Definition: vssym32.h:160
#define TMT_DISPLAYNAME
Definition: vssym32.h:154
#define TMT_AUTHOR
Definition: vssym32.h:157
#define TMT_COPYRIGHT
Definition: vssym32.h:158
#define LMEM_ZEROINIT
Definition: winbase.h:401
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MAKEINTATOM(i)
Definition: winbase.h:1488
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:575
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
DWORD COLORREF
Definition: windef.h:300
#define WINAPI
Definition: msvc.h:6
#define E_HANDLE
Definition: winerror.h:2850
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define E_POINTER
Definition: winerror.h:2365
#define HKEY_CURRENT_USER
Definition: winreg.h:11
DWORD WINAPI GetSysColor(_In_ int)
BOOL WINAPI IsWindow(_In_opt_ HWND)
HANDLE WINAPI RemovePropW(_In_ HWND, _In_ LPCWSTR)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1383
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define SPIF_SENDCHANGE
Definition: winuser.h:1575
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1574
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
#define SPI_SETICONTITLELOGFONT
Definition: winuser.h:1386
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193