imagehlp: Use the IMAGE_FIRST_SECTION helper macro.
[wine.git] / dlls / uxtheme / system.c
blob25f495d29f383dd1ec25ca26b4453be109ea7684
1 /*
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28 #include "winreg.h"
29 #include "vfwmsgs.h"
30 #include "uxtheme.h"
31 #include "vssym32.h"
33 #include "uxthemedll.h"
34 #include "msstyles.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
40 /***********************************************************************
41 * Defines and global variables
44 static const WCHAR szThemeManager[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\ThemeManager";
46 DECLSPEC_HIDDEN ATOM atDialogThemeEnabled;
48 static DWORD dwThemeAppProperties = STAP_ALLOW_NONCLIENT | STAP_ALLOW_CONTROLS;
49 static ATOM atWindowTheme;
50 static ATOM atSubAppName;
51 static ATOM atSubIdList;
53 static BOOL bThemeActive = FALSE;
54 static WCHAR szCurrentTheme[MAX_PATH];
55 static WCHAR szCurrentColor[64];
56 static WCHAR szCurrentSize[64];
58 struct user_api_hook user_api = {0};
60 /***********************************************************************/
62 static BOOL CALLBACK UXTHEME_broadcast_msg_enumchild (HWND hWnd, LPARAM msg)
64 PostMessageW(hWnd, msg, 0, 0);
65 return TRUE;
68 /* Broadcast a message to *all* windows, including children */
69 static BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg)
71 if (hWnd == NULL)
73 EnumWindows (UXTHEME_broadcast_msg, msg);
75 else
77 PostMessageW(hWnd, msg, 0, 0);
78 EnumChildWindows (hWnd, UXTHEME_broadcast_msg_enumchild, msg);
80 return TRUE;
83 /* At the end of the day this is a subset of what SHRegGetPath() does - copied
84 * here to avoid linking against shlwapi. */
85 static DWORD query_reg_path (HKEY hKey, LPCWSTR lpszValue,
86 LPVOID pvData)
88 DWORD dwRet, dwType, dwUnExpDataLen = MAX_PATH * sizeof(WCHAR), dwExpDataLen;
90 TRACE("(hkey=%p,%s,%p)\n", hKey, debugstr_w(lpszValue),
91 pvData);
93 dwRet = RegQueryValueExW(hKey, lpszValue, 0, &dwType, pvData, &dwUnExpDataLen);
94 if (dwRet!=ERROR_SUCCESS && dwRet!=ERROR_MORE_DATA)
95 return dwRet;
97 if (dwType == REG_EXPAND_SZ)
99 DWORD nBytesToAlloc;
101 /* Expand type REG_EXPAND_SZ into REG_SZ */
102 LPWSTR szData;
104 /* If the caller didn't supply a buffer or the buffer is too small we have
105 * to allocate our own
107 if (dwRet == ERROR_MORE_DATA)
109 WCHAR emptyW[] = L"";
110 nBytesToAlloc = dwUnExpDataLen;
112 szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc);
113 RegQueryValueExW (hKey, lpszValue, 0, NULL, (LPBYTE)szData, &nBytesToAlloc);
114 dwExpDataLen = ExpandEnvironmentStringsW(szData, emptyW, 1);
115 dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
116 LocalFree(szData);
118 else
120 nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR);
121 szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc );
122 lstrcpyW(szData, pvData);
123 dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, MAX_PATH );
124 if (dwExpDataLen > MAX_PATH) dwRet = ERROR_MORE_DATA;
125 dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
126 LocalFree(szData);
130 return dwRet;
133 /***********************************************************************
134 * UXTHEME_LoadTheme
136 * Set the current active theme from the registry
138 static void UXTHEME_LoadTheme(void)
140 HKEY hKey;
141 DWORD buffsize;
142 HRESULT hr;
143 WCHAR tmp[10];
144 PTHEME_FILE pt;
146 /* Get current theme configuration */
147 if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
148 TRACE("Loading theme config\n");
149 buffsize = sizeof(tmp);
150 if (!RegQueryValueExW(hKey, L"ThemeActive", NULL, NULL, (BYTE*)tmp, &buffsize)) {
151 bThemeActive = (tmp[0] != '0');
153 else {
154 bThemeActive = FALSE;
155 TRACE("Failed to get ThemeActive: %ld\n", GetLastError());
157 buffsize = sizeof(szCurrentColor);
158 if (RegQueryValueExW(hKey, L"ColorName", NULL, NULL, (BYTE*)szCurrentColor, &buffsize))
159 szCurrentColor[0] = '\0';
160 buffsize = sizeof(szCurrentSize);
161 if (RegQueryValueExW(hKey, L"SizeName", NULL, NULL, (BYTE*)szCurrentSize, &buffsize))
162 szCurrentSize[0] = '\0';
163 if (query_reg_path (hKey, L"DllName", szCurrentTheme))
164 szCurrentTheme[0] = '\0';
165 RegCloseKey(hKey);
167 else
168 TRACE("Failed to open theme registry key\n");
170 if(bThemeActive) {
171 /* Make sure the theme requested is actually valid */
172 hr = MSSTYLES_OpenThemeFile(szCurrentTheme,
173 szCurrentColor[0]?szCurrentColor:NULL,
174 szCurrentSize[0]?szCurrentSize:NULL,
175 &pt);
176 if(FAILED(hr)) {
177 bThemeActive = FALSE;
178 szCurrentTheme[0] = '\0';
179 szCurrentColor[0] = '\0';
180 szCurrentSize[0] = '\0';
182 else {
183 /* Make sure the global color & size match the theme */
184 lstrcpynW(szCurrentColor, pt->pszSelectedColor, ARRAY_SIZE(szCurrentColor));
185 lstrcpynW(szCurrentSize, pt->pszSelectedSize, ARRAY_SIZE(szCurrentSize));
187 UXTHEME_SetActiveTheme(pt);
188 TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme),
189 debugstr_w(szCurrentColor), debugstr_w(szCurrentSize));
190 MSSTYLES_CloseThemeFile(pt);
193 if(!bThemeActive) {
194 MSSTYLES_SetActiveTheme(NULL, FALSE);
195 TRACE("Theming not active\n");
199 /***********************************************************************/
201 static const WCHAR * const SysColorsNames[] =
203 L"Scrollbar", /* COLOR_SCROLLBAR */
204 L"Background", /* COLOR_BACKGROUND */
205 L"ActiveTitle", /* COLOR_ACTIVECAPTION */
206 L"InactiveTitle", /* COLOR_INACTIVECAPTION */
207 L"Menu", /* COLOR_MENU */
208 L"Window", /* COLOR_WINDOW */
209 L"WindowFrame", /* COLOR_WINDOWFRAME */
210 L"MenuText", /* COLOR_MENUTEXT */
211 L"WindowText", /* COLOR_WINDOWTEXT */
212 L"TitleText", /* COLOR_CAPTIONTEXT */
213 L"ActiveBorder", /* COLOR_ACTIVEBORDER */
214 L"InactiveBorder", /* COLOR_INACTIVEBORDER */
215 L"AppWorkSpace", /* COLOR_APPWORKSPACE */
216 L"Hilight", /* COLOR_HIGHLIGHT */
217 L"HilightText", /* COLOR_HIGHLIGHTTEXT */
218 L"ButtonFace", /* COLOR_BTNFACE */
219 L"ButtonShadow", /* COLOR_BTNSHADOW */
220 L"GrayText", /* COLOR_GRAYTEXT */
221 L"ButtonText", /* COLOR_BTNTEXT */
222 L"InactiveTitleText", /* COLOR_INACTIVECAPTIONTEXT */
223 L"ButtonHilight", /* COLOR_BTNHIGHLIGHT */
224 L"ButtonDkShadow", /* COLOR_3DDKSHADOW */
225 L"ButtonLight", /* COLOR_3DLIGHT */
226 L"InfoText", /* COLOR_INFOTEXT */
227 L"InfoWindow", /* COLOR_INFOBK */
228 L"ButtonAlternateFace", /* COLOR_ALTERNATEBTNFACE */
229 L"HotTrackingColor", /* COLOR_HOTLIGHT */
230 L"GradientActiveTitle", /* COLOR_GRADIENTACTIVECAPTION */
231 L"GradientInactiveTitle", /* COLOR_GRADIENTINACTIVECAPTION */
232 L"MenuHilight", /* COLOR_MENUHILIGHT */
233 L"MenuBar", /* COLOR_MENUBAR */
236 static const WCHAR strColorKey[] = L"Control Panel\\Colors";
238 #define NUM_SYS_COLORS (COLOR_MENUBAR+1)
240 struct system_metrics
242 COLORREF system_colors[NUM_SYS_COLORS];
243 NONCLIENTMETRICSW non_client_metrics;
244 LOGFONTW icon_title_font;
245 DWORD gradient_caption;
246 DWORD flat_menu;
249 static BOOL UXTHEME_GetSystemMetrics(struct system_metrics *metrics)
251 DPI_AWARENESS_CONTEXT old_context;
252 BOOL ret = FALSE;
253 int i;
255 for (i = 0; i < NUM_SYS_COLORS; ++i)
256 metrics->system_colors[i] = GetSysColor(i);
258 old_context = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
260 memset(&metrics->non_client_metrics, 0, sizeof(metrics->non_client_metrics));
261 metrics->non_client_metrics.cbSize = sizeof(metrics->non_client_metrics);
262 if (!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(metrics->non_client_metrics),
263 &metrics->non_client_metrics, 0))
264 goto done;
265 memset(&metrics->icon_title_font, 0, sizeof(metrics->icon_title_font));
266 if (!SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(metrics->icon_title_font),
267 &metrics->icon_title_font, 0))
268 goto done;
269 if (!SystemParametersInfoW(SPI_GETGRADIENTCAPTIONS, 0, &metrics->gradient_caption, 0))
270 goto done;
271 if (!SystemParametersInfoW(SPI_GETFLATMENU, 0, &metrics->flat_menu, 0))
272 goto done;
274 ret = TRUE;
275 done:
276 SetThreadDpiAwarenessContext(old_context);
277 return ret;
280 /* Read back old settings after a theme was deactivated */
281 static BOOL UXTHEME_GetUnthemedSystemMetrics(struct system_metrics *metrics)
283 HKEY theme_manager_key = NULL, color_key = NULL;
284 BOOL ret = FALSE;
285 WCHAR string[13];
286 int i, r, g, b;
287 DWORD size;
289 if (RegOpenKeyExW(HKEY_CURRENT_USER, szThemeManager, 0, KEY_QUERY_VALUE, &theme_manager_key))
290 goto done;
292 if (RegOpenKeyExW(theme_manager_key, strColorKey, 0, KEY_QUERY_VALUE, &color_key))
293 goto done;
295 for (i = 0; i < NUM_SYS_COLORS; ++i)
297 size = sizeof(string);
298 if (RegQueryValueExW(color_key, SysColorsNames[i], 0, NULL, (BYTE *)string, &size))
299 goto done;
301 if (swscanf(string, L"%d %d %d", &r, &g, &b) != 3)
302 goto done;
304 metrics->system_colors[i] = RGB(r, g, b);
307 size = sizeof(metrics->non_client_metrics);
308 if (RegQueryValueExW(theme_manager_key, L"NonClientMetrics", 0, NULL,
309 (BYTE *)&metrics->non_client_metrics, &size))
310 goto done;
311 size = sizeof(metrics->icon_title_font);
312 if (RegQueryValueExW(theme_manager_key, L"IconTitleFont", 0, NULL,
313 (BYTE *)&metrics->icon_title_font, &size))
314 goto done;
315 size = sizeof(metrics->gradient_caption);
316 if (RegQueryValueExW(theme_manager_key, L"GradientCaption", 0, NULL,
317 (BYTE *)&metrics->gradient_caption, &size))
318 goto done;
319 size = sizeof(metrics->flat_menu);
320 if (RegQueryValueExW(theme_manager_key, L"FlatMenu", 0, NULL, (BYTE *)&metrics->flat_menu,
321 &size))
322 goto done;
324 ret = TRUE;
325 done:
326 RegCloseKey(color_key);
327 RegCloseKey(theme_manager_key);
328 return ret;
331 static void UXTHEME_SaveUnthemedSystemMetrics(struct system_metrics *metrics)
333 HKEY theme_manager_key, color_key;
334 WCHAR string[13];
335 DWORD length;
336 int i;
338 if (!RegCreateKeyExW(HKEY_CURRENT_USER, szThemeManager, 0, 0, 0, KEY_ALL_ACCESS, 0,
339 &theme_manager_key, 0))
341 if (!RegCreateKeyExW(theme_manager_key, strColorKey, 0, 0, 0, KEY_ALL_ACCESS, 0, &color_key,
344 for (i = 0; i < NUM_SYS_COLORS; ++i)
346 length = swprintf(string, ARRAY_SIZE(string), L"%d %d %d",
347 GetRValue(metrics->system_colors[i]),
348 GetGValue(metrics->system_colors[i]),
349 GetBValue(metrics->system_colors[i]));
350 RegSetValueExW(color_key, SysColorsNames[i], 0, REG_SZ, (BYTE *)string,
351 (length + 1) * sizeof(WCHAR));
354 RegCloseKey(color_key);
357 RegSetValueExW(theme_manager_key, L"NonClientMetrics", 0, REG_BINARY,
358 (BYTE *)&metrics->non_client_metrics, sizeof(metrics->non_client_metrics));
359 RegSetValueExW(theme_manager_key, L"IconTitleFont", 0, REG_BINARY,
360 (BYTE *)&metrics->icon_title_font, sizeof(metrics->icon_title_font));
361 RegSetValueExW(theme_manager_key, L"GradientCaption", 0, REG_DWORD,
362 (BYTE *)&metrics->gradient_caption, sizeof(metrics->gradient_caption));
363 RegSetValueExW(theme_manager_key, L"FlatMenu", 0, REG_DWORD, (BYTE *)&metrics->flat_menu,
364 sizeof(metrics->flat_menu));
365 RegCloseKey(theme_manager_key);
369 /* Make system settings persistent, so they're in effect even w/o uxtheme
370 * loaded.
371 * For efficiency reasons, only the last SystemParametersInfoW sets
372 * SPIF_SENDWININICHANGE */
373 static void UXTHEME_SaveSystemMetrics(struct system_metrics *metrics, BOOL send_syscolor_change)
375 int i, length, index[NUM_SYS_COLORS];
376 DPI_AWARENESS_CONTEXT old_context;
377 WCHAR string[13];
378 HKEY hkey;
380 if (!RegCreateKeyExW(HKEY_CURRENT_USER, strColorKey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hkey, 0))
382 for (i = 0; i < NUM_SYS_COLORS; ++i)
384 length = swprintf(string, ARRAY_SIZE(string), L"%d %d %d",
385 GetRValue(metrics->system_colors[i]),
386 GetGValue(metrics->system_colors[i]),
387 GetBValue(metrics->system_colors[i]));
388 RegSetValueExW(hkey, SysColorsNames[i], 0, REG_SZ, (BYTE *)string,
389 (length + 1) * sizeof(WCHAR));
391 RegCloseKey(hkey);
394 if (send_syscolor_change)
396 for (i = 0; i < NUM_SYS_COLORS; ++i)
397 index[i] = i;
399 SetSysColors(NUM_SYS_COLORS, index, metrics->system_colors);
402 old_context = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
404 SystemParametersInfoW(SPI_SETNONCLIENTMETRICS, sizeof(metrics->non_client_metrics),
405 &metrics->non_client_metrics, SPIF_UPDATEINIFILE);
406 SystemParametersInfoW(SPI_SETICONTITLELOGFONT, sizeof(metrics->icon_title_font),
407 &metrics->icon_title_font, SPIF_UPDATEINIFILE);
408 SystemParametersInfoW(SPI_SETGRADIENTCAPTIONS, 0, (void *)(INT_PTR)metrics->gradient_caption,
409 SPIF_UPDATEINIFILE);
410 SystemParametersInfoW(SPI_SETFLATMENU, 0, (void *)(INT_PTR)metrics->flat_menu,
411 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
413 SetThreadDpiAwarenessContext(old_context);
416 /***********************************************************************
417 * UXTHEME_SetActiveTheme
419 * Change the current active theme
421 HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
423 BOOL ret, loaded_before = FALSE, same_theme = FALSE;
424 struct system_metrics metrics;
425 DWORD size;
426 HKEY hKey;
427 WCHAR tmp[2];
428 HRESULT hr;
430 if(tf) {
431 bThemeActive = TRUE;
432 same_theme = !lstrcmpW(szCurrentTheme, tf->szThemeFile)
433 && !lstrcmpW(szCurrentColor, tf->pszSelectedColor)
434 && !lstrcmpW(szCurrentSize, tf->pszSelectedSize);
435 lstrcpynW(szCurrentTheme, tf->szThemeFile, ARRAY_SIZE(szCurrentTheme));
436 lstrcpynW(szCurrentColor, tf->pszSelectedColor, ARRAY_SIZE(szCurrentColor));
437 lstrcpynW(szCurrentSize, tf->pszSelectedSize, ARRAY_SIZE(szCurrentSize));
439 ret = UXTHEME_GetSystemMetrics(&metrics);
441 /* Check if theming is already active */
442 if (!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey))
444 size = sizeof(tmp);
445 if (!RegQueryValueExW(hKey, L"LoadedBefore", NULL, NULL, (BYTE *)tmp, &size))
446 loaded_before = (tmp[0] != '0');
447 else
448 WARN("Failed to get LoadedBefore: %ld\n", GetLastError());
449 RegCloseKey(hKey);
451 if (loaded_before && same_theme)
452 return MSSTYLES_SetActiveTheme(tf, FALSE);
454 if (!loaded_before && ret)
455 UXTHEME_SaveUnthemedSystemMetrics(&metrics);
457 else {
458 bThemeActive = FALSE;
459 szCurrentTheme[0] = '\0';
460 szCurrentColor[0] = '\0';
461 szCurrentSize[0] = '\0';
464 TRACE("Writing theme config to registry\n");
465 if(!RegCreateKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
466 tmp[0] = bThemeActive?'1':'0';
467 tmp[1] = '\0';
468 RegSetValueExW(hKey, L"ThemeActive", 0, REG_SZ, (const BYTE*)tmp, sizeof(WCHAR)*2);
469 if(bThemeActive) {
470 RegSetValueExW(hKey, L"ColorName", 0, REG_SZ, (const BYTE*)szCurrentColor,
471 (lstrlenW(szCurrentColor)+1)*sizeof(WCHAR));
472 RegSetValueExW(hKey, L"SizeName", 0, REG_SZ, (const BYTE*)szCurrentSize,
473 (lstrlenW(szCurrentSize)+1)*sizeof(WCHAR));
474 RegSetValueExW(hKey, L"DllName", 0, REG_SZ, (const BYTE*)szCurrentTheme,
475 (lstrlenW(szCurrentTheme)+1)*sizeof(WCHAR));
476 RegSetValueExW(hKey, L"LoadedBefore", 0, REG_SZ, (const BYTE *)tmp, sizeof(WCHAR) * 2);
478 else {
479 RegDeleteValueW(hKey, L"ColorName");
480 RegDeleteValueW(hKey, L"SizeName");
481 RegDeleteValueW(hKey, L"DllName");
482 RegDeleteValueW(hKey, L"LoadedBefore");
484 RegCloseKey(hKey);
486 else
487 TRACE("Failed to open theme registry key\n");
489 hr = MSSTYLES_SetActiveTheme(tf, TRUE);
490 if (bThemeActive)
492 if (UXTHEME_GetSystemMetrics(&metrics))
493 UXTHEME_SaveSystemMetrics(&metrics, FALSE);
495 else
497 if (UXTHEME_GetUnthemedSystemMetrics(&metrics))
498 UXTHEME_SaveSystemMetrics(&metrics, TRUE);
500 return hr;
503 /***********************************************************************
504 * UXTHEME_InitSystem
506 void UXTHEME_InitSystem(HINSTANCE hInst)
508 atWindowTheme = GlobalAddAtomW(L"ux_theme");
509 atSubAppName = GlobalAddAtomW(L"ux_subapp");
510 atSubIdList = GlobalAddAtomW(L"ux_subidlst");
511 atDialogThemeEnabled = GlobalAddAtomW(L"ux_dialogtheme");
513 UXTHEME_LoadTheme();
514 ThemeHooksInstall();
517 void UXTHEME_UninitSystem(void)
519 ThemeHooksRemove();
520 MSSTYLES_SetActiveTheme(NULL, FALSE);
522 GlobalDeleteAtom(atWindowTheme);
523 GlobalDeleteAtom(atSubAppName);
524 GlobalDeleteAtom(atSubIdList);
525 GlobalDeleteAtom(atDialogThemeEnabled);
528 /***********************************************************************
529 * IsAppThemed (UXTHEME.@)
531 BOOL WINAPI IsAppThemed(void)
533 return IsThemeActive();
536 /***********************************************************************
537 * IsThemeActive (UXTHEME.@)
539 BOOL WINAPI IsThemeActive(void)
541 TRACE("\n");
542 SetLastError(ERROR_SUCCESS);
543 return bThemeActive;
546 /************************************************************
547 * IsCompositionActive (UXTHEME.@)
549 BOOL WINAPI IsCompositionActive(void)
551 FIXME(": stub\n");
553 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
555 return FALSE;
558 /***********************************************************************
559 * EnableTheming (UXTHEME.@)
561 * NOTES
562 * This is a global and persistent change
564 HRESULT WINAPI EnableTheming(BOOL fEnable)
566 HKEY hKey;
568 TRACE("(%d)\n", fEnable);
570 if (bThemeActive && !fEnable)
572 bThemeActive = fEnable;
573 if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
574 RegSetValueExW(hKey, L"ThemeActive", 0, REG_SZ, (BYTE *)L"0", 2 * sizeof(WCHAR));
575 RegCloseKey(hKey);
577 UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
579 return S_OK;
582 /***********************************************************************
583 * UXTHEME_SetWindowProperty
585 * I'm using atoms as there may be large numbers of duplicated strings
586 * and they do the work of keeping memory down as a cause of that quite nicely
588 static HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue)
590 ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
591 if(oldValue)
592 DeleteAtom(oldValue);
593 if(pszValue) {
594 ATOM atValue = AddAtomW(pszValue);
595 if(!atValue
596 || !SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp), (LPWSTR)MAKEINTATOM(atValue))) {
597 HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
598 if(atValue) DeleteAtom(atValue);
599 return hr;
602 return S_OK;
605 static LPWSTR UXTHEME_GetWindowProperty(HWND hwnd, ATOM aProp, LPWSTR pszBuffer, int dwLen)
607 ATOM atValue = (ATOM)(size_t)GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
608 if(atValue) {
609 if(GetAtomNameW(atValue, pszBuffer, dwLen))
610 return pszBuffer;
611 TRACE("property defined, but unable to get value\n");
613 return NULL;
616 static HTHEME open_theme_data(HWND hwnd, LPCWSTR pszClassList, DWORD flags, UINT dpi)
618 WCHAR szAppBuff[256];
619 WCHAR szClassBuff[256];
620 LPCWSTR pszAppName;
621 LPCWSTR pszUseClassList;
622 HTHEME hTheme = NULL;
623 TRACE("(%p,%s, %lx)\n", hwnd, debugstr_w(pszClassList), flags);
625 if(!pszClassList)
627 SetLastError(E_POINTER);
628 return NULL;
631 if(flags)
632 FIXME("unhandled flags: %lx\n", flags);
634 if(bThemeActive)
636 pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, ARRAY_SIZE(szAppBuff));
637 /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */
638 pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, ARRAY_SIZE(szClassBuff));
639 if(!pszUseClassList)
640 pszUseClassList = pszClassList;
642 if (pszUseClassList)
643 hTheme = MSSTYLES_OpenThemeClass(pszAppName, pszUseClassList, dpi);
645 /* Fall back to default class if the specified subclass is not found */
646 if (!hTheme)
647 hTheme = MSSTYLES_OpenThemeClass(NULL, pszUseClassList, dpi);
649 if(IsWindow(hwnd))
650 SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme), hTheme);
651 TRACE(" = %p\n", hTheme);
653 SetLastError(hTheme ? ERROR_SUCCESS : E_PROP_ID_UNSUPPORTED);
654 return hTheme;
657 /***********************************************************************
658 * OpenThemeDataEx (UXTHEME.61)
660 HTHEME WINAPI OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD flags)
662 UINT dpi;
664 dpi = GetDpiForWindow(hwnd);
665 if (!dpi)
666 dpi = GetDpiForSystem();
668 return open_theme_data(hwnd, pszClassList, flags, dpi);
671 /***********************************************************************
672 * OpenThemeDataForDpi (UXTHEME.@)
674 HTHEME WINAPI OpenThemeDataForDpi(HWND hwnd, LPCWSTR class_list, UINT dpi)
676 return open_theme_data(hwnd, class_list, 0, dpi);
679 /***********************************************************************
680 * OpenThemeData (UXTHEME.@)
682 HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
684 return OpenThemeDataEx(hwnd, classlist, 0);
687 /***********************************************************************
688 * GetWindowTheme (UXTHEME.@)
690 * Retrieve the last theme opened for a window.
692 * PARAMS
693 * hwnd [I] window to retrieve the theme for
695 * RETURNS
696 * The most recent theme.
698 HTHEME WINAPI GetWindowTheme(HWND hwnd)
700 TRACE("(%p)\n", hwnd);
702 if (!hwnd)
704 SetLastError(E_HANDLE);
705 return NULL;
708 return GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme));
711 /***********************************************************************
712 * SetWindowTheme (UXTHEME.@)
714 * Persistent through the life of the window, even after themes change
716 HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
717 LPCWSTR pszSubIdList)
719 HRESULT hr;
720 TRACE("(%p,%s,%s)\n", hwnd, debugstr_w(pszSubAppName),
721 debugstr_w(pszSubIdList));
723 if (!hwnd)
724 return E_HANDLE;
726 hr = UXTHEME_SetWindowProperty(hwnd, atSubAppName, pszSubAppName);
727 if(SUCCEEDED(hr))
728 hr = UXTHEME_SetWindowProperty(hwnd, atSubIdList, pszSubIdList);
729 if(SUCCEEDED(hr))
730 SendMessageW(hwnd, WM_THEMECHANGED, 0, 0);
731 return hr;
734 /***********************************************************************
735 * SetWindowThemeAttribute (UXTHEME.@)
737 HRESULT WINAPI SetWindowThemeAttribute(HWND hwnd, enum WINDOWTHEMEATTRIBUTETYPE type,
738 PVOID attribute, DWORD size)
740 FIXME("(%p,%d,%p,%ld): stub\n", hwnd, type, attribute, size);
741 return E_NOTIMPL;
744 /***********************************************************************
745 * GetCurrentThemeName (UXTHEME.@)
747 HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars,
748 LPWSTR pszColorBuff, int cchMaxColorChars,
749 LPWSTR pszSizeBuff, int cchMaxSizeChars)
751 if(!bThemeActive)
752 return E_PROP_ID_UNSUPPORTED;
753 if(pszThemeFileName) lstrcpynW(pszThemeFileName, szCurrentTheme, dwMaxNameChars);
754 if(pszColorBuff) lstrcpynW(pszColorBuff, szCurrentColor, cchMaxColorChars);
755 if(pszSizeBuff) lstrcpynW(pszSizeBuff, szCurrentSize, cchMaxSizeChars);
756 return S_OK;
759 /***********************************************************************
760 * GetThemeAppProperties (UXTHEME.@)
762 DWORD WINAPI GetThemeAppProperties(void)
764 return dwThemeAppProperties;
767 /***********************************************************************
768 * SetThemeAppProperties (UXTHEME.@)
770 void WINAPI SetThemeAppProperties(DWORD dwFlags)
772 TRACE("(0x%08lx)\n", dwFlags);
773 dwThemeAppProperties = dwFlags;
776 /***********************************************************************
777 * CloseThemeData (UXTHEME.@)
779 HRESULT WINAPI CloseThemeData(HTHEME hTheme)
781 TRACE("(%p)\n", hTheme);
782 if(!hTheme || hTheme == INVALID_HANDLE_VALUE)
783 return E_HANDLE;
784 return MSSTYLES_CloseThemeClass(hTheme);
787 /***********************************************************************
788 * HitTestThemeBackground (UXTHEME.@)
790 HRESULT WINAPI HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId,
791 int iStateId, DWORD dwOptions,
792 const RECT *pRect, HRGN hrgn,
793 POINT ptTest, WORD *pwHitTestCode)
795 FIXME("%d %d 0x%08lx: stub\n", iPartId, iStateId, dwOptions);
796 if(!hTheme)
797 return E_HANDLE;
798 return E_NOTIMPL;
801 /***********************************************************************
802 * IsThemePartDefined (UXTHEME.@)
804 BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId)
806 TRACE("(%p,%d,%d)\n", hTheme, iPartId, iStateId);
807 if(!hTheme) {
808 SetLastError(E_HANDLE);
809 return FALSE;
812 SetLastError(NO_ERROR);
813 return !iStateId && MSSTYLES_FindPart(hTheme, iPartId);
816 /***********************************************************************
817 * GetThemeDocumentationProperty (UXTHEME.@)
819 * Try and retrieve the documentation property from string resources
820 * if that fails, get it from the [documentation] section of themes.ini
822 HRESULT WINAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName,
823 LPCWSTR pszPropertyName,
824 LPWSTR pszValueBuff,
825 int cchMaxValChars)
827 static const WORD wDocToRes[] = {
828 TMT_DISPLAYNAME,5000,
829 TMT_TOOLTIP,5001,
830 TMT_COMPANY,5002,
831 TMT_AUTHOR,5003,
832 TMT_COPYRIGHT,5004,
833 TMT_URL,5005,
834 TMT_VERSION,5006,
835 TMT_DESCRIPTION,5007
838 PTHEME_FILE pt;
839 HRESULT hr;
840 unsigned int i;
841 int iDocId;
842 TRACE("(%s,%s,%p,%d)\n", debugstr_w(pszThemeName), debugstr_w(pszPropertyName),
843 pszValueBuff, cchMaxValChars);
845 hr = MSSTYLES_OpenThemeFile(pszThemeName, NULL, NULL, &pt);
846 if(FAILED(hr)) return hr;
848 /* Try to load from string resources */
849 hr = E_PROP_ID_UNSUPPORTED;
850 if(MSSTYLES_LookupProperty(pszPropertyName, NULL, &iDocId)) {
851 for(i=0; i<ARRAY_SIZE(wDocToRes); i+=2) {
852 if(wDocToRes[i] == iDocId) {
853 if(LoadStringW(pt->hTheme, wDocToRes[i+1], pszValueBuff, cchMaxValChars)) {
854 hr = S_OK;
855 break;
860 /* If loading from string resource failed, try getting it from the theme.ini */
861 if(FAILED(hr)) {
862 PUXINI_FILE uf = MSSTYLES_GetThemeIni(pt);
863 if(UXINI_FindSection(uf, L"documentation")) {
864 LPCWSTR lpValue;
865 DWORD dwLen;
866 if(UXINI_FindValue(uf, pszPropertyName, &lpValue, &dwLen)) {
867 lstrcpynW(pszValueBuff, lpValue, min(dwLen+1,cchMaxValChars));
868 hr = S_OK;
871 UXINI_CloseINI(uf);
874 MSSTYLES_CloseThemeFile(pt);
875 return hr;
878 /**********************************************************************
879 * Undocumented functions
882 /**********************************************************************
883 * QueryThemeServices (UXTHEME.1)
885 * RETURNS
886 * some kind of status flag
888 DWORD WINAPI QueryThemeServices(void)
890 FIXME("stub\n");
891 return 3; /* This is what is returned under XP in most cases */
895 /**********************************************************************
896 * OpenThemeFile (UXTHEME.2)
898 * Opens a theme file, which can be used to change the current theme, etc
900 * PARAMS
901 * pszThemeFileName Path to a msstyles theme file
902 * pszColorName Color defined in the theme, eg. NormalColor
903 * pszSizeName Size defined in the theme, eg. NormalSize
904 * hThemeFile Handle to theme file
906 * RETURNS
907 * Success: S_OK
908 * Failure: HRESULT error-code
910 HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName,
911 LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile,
912 DWORD unknown)
914 TRACE("(%s,%s,%s,%p,%ld)\n", debugstr_w(pszThemeFileName),
915 debugstr_w(pszColorName), debugstr_w(pszSizeName),
916 hThemeFile, unknown);
917 return MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, (PTHEME_FILE*)hThemeFile);
920 /**********************************************************************
921 * CloseThemeFile (UXTHEME.3)
923 * Releases theme file handle returned by OpenThemeFile
925 * PARAMS
926 * hThemeFile Handle to theme file
928 * RETURNS
929 * Success: S_OK
930 * Failure: HRESULT error-code
932 HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile)
934 TRACE("(%p)\n", hThemeFile);
935 MSSTYLES_CloseThemeFile(hThemeFile);
936 return S_OK;
939 /**********************************************************************
940 * ApplyTheme (UXTHEME.4)
942 * Set a theme file to be the currently active theme
944 * PARAMS
945 * hThemeFile Handle to theme file
946 * unknown See notes
947 * hWnd Window requesting the theme change
949 * RETURNS
950 * Success: S_OK
951 * Failure: HRESULT error-code
953 * NOTES
954 * I'm not sure what the second parameter is (the datatype is likely wrong), other then this:
955 * Under XP if I pass
956 * char b[] = "";
957 * the theme is applied with the screen redrawing really badly (flickers)
958 * char b[] = "\0"; where \0 can be one or more of any character, makes no difference
959 * the theme is applied smoothly (screen does not flicker)
960 * char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference
961 * the function fails returning invalid parameter... very strange
963 HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd)
965 HRESULT hr;
966 TRACE("(%p,%s,%p)\n", hThemeFile, unknown, hWnd);
967 hr = UXTHEME_SetActiveTheme(hThemeFile);
968 UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
969 return hr;
972 /**********************************************************************
973 * GetThemeDefaults (UXTHEME.7)
975 * Get the default color & size for a theme
977 * PARAMS
978 * pszThemeFileName Path to a msstyles theme file
979 * pszColorName Buffer to receive the default color name
980 * dwColorNameLen Length, in characters, of color name buffer
981 * pszSizeName Buffer to receive the default size name
982 * dwSizeNameLen Length, in characters, of size name buffer
984 * RETURNS
985 * Success: S_OK
986 * Failure: HRESULT error-code
988 HRESULT WINAPI GetThemeDefaults(LPCWSTR pszThemeFileName, LPWSTR pszColorName,
989 DWORD dwColorNameLen, LPWSTR pszSizeName,
990 DWORD dwSizeNameLen)
992 PTHEME_FILE pt;
993 HRESULT hr;
994 TRACE("(%s,%p,%ld,%p,%ld)\n", debugstr_w(pszThemeFileName),
995 pszColorName, dwColorNameLen,
996 pszSizeName, dwSizeNameLen);
998 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
999 if(FAILED(hr)) return hr;
1001 lstrcpynW(pszColorName, pt->pszSelectedColor, dwColorNameLen);
1002 lstrcpynW(pszSizeName, pt->pszSelectedSize, dwSizeNameLen);
1004 MSSTYLES_CloseThemeFile(pt);
1005 return S_OK;
1008 /**********************************************************************
1009 * EnumThemes (UXTHEME.8)
1011 * Enumerate available themes, calls specified EnumThemeProc for each
1012 * theme found. Passes lpData through to callback function.
1014 * PARAMS
1015 * pszThemePath Path containing themes
1016 * callback Called for each theme found in path
1017 * lpData Passed through to callback
1019 * RETURNS
1020 * Success: S_OK
1021 * Failure: HRESULT error-code
1023 HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, EnumThemeProc callback,
1024 LPVOID lpData)
1026 WCHAR szDir[MAX_PATH];
1027 WCHAR szPath[MAX_PATH];
1028 WCHAR szName[60];
1029 WCHAR szTip[60];
1030 HANDLE hFind;
1031 WIN32_FIND_DATAW wfd;
1032 HRESULT hr;
1033 size_t pathLen;
1035 TRACE("(%s,%p,%p)\n", debugstr_w(pszThemePath), callback, lpData);
1037 if(!pszThemePath || !callback)
1038 return E_POINTER;
1040 lstrcpyW(szDir, pszThemePath);
1041 pathLen = lstrlenW (szDir);
1042 if ((pathLen > 0) && (pathLen < MAX_PATH-1) && (szDir[pathLen - 1] != '\\'))
1044 szDir[pathLen] = '\\';
1045 szDir[pathLen+1] = 0;
1048 lstrcpyW(szPath, szDir);
1049 lstrcatW(szPath, L"*.*");
1050 TRACE("searching %s\n", debugstr_w(szPath));
1052 hFind = FindFirstFileW(szPath, &wfd);
1053 if(hFind != INVALID_HANDLE_VALUE) {
1054 do {
1055 if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
1056 && !(wfd.cFileName[0] == '.' && ((wfd.cFileName[1] == '.' && wfd.cFileName[2] == 0) || wfd.cFileName[1] == 0))) {
1057 wsprintfW(szPath, L"%s%s\\%s.msstyles", szDir, wfd.cFileName, wfd.cFileName);
1059 hr = GetThemeDocumentationProperty(szPath, L"displayname", szName, ARRAY_SIZE(szName));
1060 if(SUCCEEDED(hr))
1061 hr = GetThemeDocumentationProperty(szPath, L"tooltip", szTip, ARRAY_SIZE(szTip));
1062 if(SUCCEEDED(hr)) {
1063 TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath), debugstr_w(szName), debugstr_w(szTip), lpData);
1064 if(!callback(NULL, szPath, szName, szTip, NULL, lpData)) {
1065 TRACE("callback ended enum\n");
1066 break;
1070 } while(FindNextFileW(hFind, &wfd));
1071 FindClose(hFind);
1073 return S_OK;
1077 /**********************************************************************
1078 * EnumThemeColors (UXTHEME.9)
1080 * Enumerate theme colors available with a particular size
1082 * PARAMS
1083 * pszThemeFileName Path to a msstyles theme file
1084 * pszSizeName Theme size to enumerate available colors
1085 * If NULL the default theme size is used
1086 * dwColorNum Color index to retrieve, increment from 0
1087 * pszColorNames Output color names
1089 * RETURNS
1090 * S_OK on success
1091 * E_PROP_ID_UNSUPPORTED when dwColorName does not refer to a color
1092 * or when pszSizeName does not refer to a valid size
1094 * NOTES
1095 * XP fails with E_POINTER when pszColorNames points to a buffer smaller than
1096 * sizeof(THEMENAMES).
1098 * Not very efficient that I'm opening & validating the theme every call, but
1099 * this is undocumented and almost never called..
1100 * (and this is how windows works too)
1102 HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName,
1103 DWORD dwColorNum, PTHEMENAMES pszColorNames)
1105 PTHEME_FILE pt;
1106 HRESULT hr;
1107 LPWSTR tmp;
1108 UINT resourceId = dwColorNum + 1000;
1109 TRACE("(%s,%s,%ld)\n", debugstr_w(pszThemeFileName),
1110 debugstr_w(pszSizeName), dwColorNum);
1112 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, pszSizeName, &pt);
1113 if(FAILED(hr)) return hr;
1115 tmp = pt->pszAvailColors;
1116 while(dwColorNum && *tmp) {
1117 dwColorNum--;
1118 tmp += lstrlenW(tmp)+1;
1120 if(!dwColorNum && *tmp) {
1121 TRACE("%s\n", debugstr_w(tmp));
1122 lstrcpyW(pszColorNames->szName, tmp);
1123 LoadStringW(pt->hTheme, resourceId, pszColorNames->szDisplayName,
1124 ARRAY_SIZE(pszColorNames->szDisplayName));
1125 LoadStringW(pt->hTheme, resourceId+1000, pszColorNames->szTooltip,
1126 ARRAY_SIZE(pszColorNames->szTooltip));
1128 else
1129 hr = E_PROP_ID_UNSUPPORTED;
1131 MSSTYLES_CloseThemeFile(pt);
1132 return hr;
1135 /**********************************************************************
1136 * EnumThemeSizes (UXTHEME.10)
1138 * Enumerate theme colors available with a particular size
1140 * PARAMS
1141 * pszThemeFileName Path to a msstyles theme file
1142 * pszColorName Theme color to enumerate available sizes
1143 * If NULL the default theme color is used
1144 * dwSizeNum Size index to retrieve, increment from 0
1145 * pszSizeNames Output size names
1147 * RETURNS
1148 * S_OK on success
1149 * E_PROP_ID_UNSUPPORTED when dwSizeName does not refer to a size
1150 * or when pszColorName does not refer to a valid color
1152 * NOTES
1153 * XP fails with E_POINTER when pszSizeNames points to a buffer smaller than
1154 * sizeof(THEMENAMES).
1156 * Not very efficient that I'm opening & validating the theme every call, but
1157 * this is undocumented and almost never called..
1158 * (and this is how windows works too)
1160 HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName,
1161 DWORD dwSizeNum, PTHEMENAMES pszSizeNames)
1163 PTHEME_FILE pt;
1164 HRESULT hr;
1165 LPWSTR tmp;
1166 UINT resourceId = dwSizeNum + 3000;
1167 TRACE("(%s,%s,%ld)\n", debugstr_w(pszThemeFileName),
1168 debugstr_w(pszColorName), dwSizeNum);
1170 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, NULL, &pt);
1171 if(FAILED(hr)) return hr;
1173 tmp = pt->pszAvailSizes;
1174 while(dwSizeNum && *tmp) {
1175 dwSizeNum--;
1176 tmp += lstrlenW(tmp)+1;
1178 if(!dwSizeNum && *tmp) {
1179 TRACE("%s\n", debugstr_w(tmp));
1180 lstrcpyW(pszSizeNames->szName, tmp);
1181 LoadStringW(pt->hTheme, resourceId, pszSizeNames->szDisplayName,
1182 ARRAY_SIZE(pszSizeNames->szDisplayName));
1183 LoadStringW(pt->hTheme, resourceId+1000, pszSizeNames->szTooltip,
1184 ARRAY_SIZE(pszSizeNames->szTooltip));
1186 else
1187 hr = E_PROP_ID_UNSUPPORTED;
1189 MSSTYLES_CloseThemeFile(pt);
1190 return hr;
1193 /**********************************************************************
1194 * ParseThemeIniFile (UXTHEME.11)
1196 * Enumerate data in a theme INI file.
1198 * PARAMS
1199 * pszIniFileName Path to a theme ini file
1200 * pszUnknown Cannot be NULL, L"" is valid
1201 * callback Called for each found entry
1202 * lpData Passed through to callback
1204 * RETURNS
1205 * S_OK on success
1206 * 0x800706488 (Unknown property) when enumeration is canceled from callback
1208 * NOTES
1209 * When pszUnknown is NULL the callback is never called, the value does not seem to serve
1210 * any other purpose
1212 HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
1213 ParseThemeIniFileProc callback, LPVOID lpData)
1215 FIXME("%s %s: stub\n", debugstr_w(pszIniFileName), debugstr_w(pszUnknown));
1216 return E_NOTIMPL;
1219 /**********************************************************************
1220 * CheckThemeSignature (UXTHEME.29)
1222 * Validates the signature of a theme file
1224 * PARAMS
1225 * pszIniFileName Path to a theme file
1227 * RETURNS
1228 * Success: S_OK
1229 * Failure: HRESULT error-code
1231 HRESULT WINAPI CheckThemeSignature(LPCWSTR pszThemeFileName)
1233 PTHEME_FILE pt;
1234 HRESULT hr;
1235 TRACE("(%s)\n", debugstr_w(pszThemeFileName));
1236 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
1237 if(FAILED(hr))
1238 return hr;
1239 MSSTYLES_CloseThemeFile(pt);
1240 return S_OK;
1243 BOOL WINAPI ThemeHooksInstall(void)
1245 struct user_api_hook hooks;
1247 hooks.pDefDlgProc = UXTHEME_DefDlgProc;
1248 hooks.pNonClientButtonDraw = UXTHEME_NonClientButtonDraw;
1249 hooks.pScrollBarDraw = UXTHEME_ScrollBarDraw;
1250 hooks.pScrollBarWndProc = UXTHEME_ScrollbarWndProc;
1251 return RegisterUserApiHook(&hooks, &user_api);
1254 BOOL WINAPI ThemeHooksRemove(void)
1256 UnregisterUserApiHook();
1257 return TRUE;