version/tests: Enable compilation with long types.
[wine.git] / dlls / uxtheme / system.c
blob908451f0fe8564933d14a70c1e5db5c3333897cf
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 RegCloseKey(hKey);
131 return dwRet;
134 /***********************************************************************
135 * UXTHEME_LoadTheme
137 * Set the current active theme from the registry
139 static void UXTHEME_LoadTheme(void)
141 HKEY hKey;
142 DWORD buffsize;
143 HRESULT hr;
144 WCHAR tmp[10];
145 PTHEME_FILE pt;
147 /* Get current theme configuration */
148 if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
149 TRACE("Loading theme config\n");
150 buffsize = sizeof(tmp);
151 if (!RegQueryValueExW(hKey, L"ThemeActive", NULL, NULL, (BYTE*)tmp, &buffsize)) {
152 bThemeActive = (tmp[0] != '0');
154 else {
155 bThemeActive = FALSE;
156 TRACE("Failed to get ThemeActive: %ld\n", GetLastError());
158 buffsize = sizeof(szCurrentColor);
159 if (RegQueryValueExW(hKey, L"ColorName", NULL, NULL, (BYTE*)szCurrentColor, &buffsize))
160 szCurrentColor[0] = '\0';
161 buffsize = sizeof(szCurrentSize);
162 if (RegQueryValueExW(hKey, L"SizeName", NULL, NULL, (BYTE*)szCurrentSize, &buffsize))
163 szCurrentSize[0] = '\0';
164 if (query_reg_path (hKey, L"DllName", szCurrentTheme))
165 szCurrentTheme[0] = '\0';
166 RegCloseKey(hKey);
168 else
169 TRACE("Failed to open theme registry key\n");
171 if(bThemeActive) {
172 /* Make sure the theme requested is actually valid */
173 hr = MSSTYLES_OpenThemeFile(szCurrentTheme,
174 szCurrentColor[0]?szCurrentColor:NULL,
175 szCurrentSize[0]?szCurrentSize:NULL,
176 &pt);
177 if(FAILED(hr)) {
178 bThemeActive = FALSE;
179 szCurrentTheme[0] = '\0';
180 szCurrentColor[0] = '\0';
181 szCurrentSize[0] = '\0';
183 else {
184 /* Make sure the global color & size match the theme */
185 lstrcpynW(szCurrentColor, pt->pszSelectedColor, ARRAY_SIZE(szCurrentColor));
186 lstrcpynW(szCurrentSize, pt->pszSelectedSize, ARRAY_SIZE(szCurrentSize));
188 UXTHEME_SetActiveTheme(pt);
189 TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme),
190 debugstr_w(szCurrentColor), debugstr_w(szCurrentSize));
191 MSSTYLES_CloseThemeFile(pt);
194 if(!bThemeActive) {
195 MSSTYLES_SetActiveTheme(NULL, FALSE);
196 TRACE("Theming not active\n");
200 /***********************************************************************/
202 static const WCHAR * const SysColorsNames[] =
204 L"Scrollbar", /* COLOR_SCROLLBAR */
205 L"Background", /* COLOR_BACKGROUND */
206 L"ActiveTitle", /* COLOR_ACTIVECAPTION */
207 L"InactiveTitle", /* COLOR_INACTIVECAPTION */
208 L"Menu", /* COLOR_MENU */
209 L"Window", /* COLOR_WINDOW */
210 L"WindowFrame", /* COLOR_WINDOWFRAME */
211 L"MenuText", /* COLOR_MENUTEXT */
212 L"WindowText", /* COLOR_WINDOWTEXT */
213 L"TitleText", /* COLOR_CAPTIONTEXT */
214 L"ActiveBorder", /* COLOR_ACTIVEBORDER */
215 L"InactiveBorder", /* COLOR_INACTIVEBORDER */
216 L"AppWorkSpace", /* COLOR_APPWORKSPACE */
217 L"Hilight", /* COLOR_HIGHLIGHT */
218 L"HilightText", /* COLOR_HIGHLIGHTTEXT */
219 L"ButtonFace", /* COLOR_BTNFACE */
220 L"ButtonShadow", /* COLOR_BTNSHADOW */
221 L"GrayText", /* COLOR_GRAYTEXT */
222 L"ButtonText", /* COLOR_BTNTEXT */
223 L"InactiveTitleText", /* COLOR_INACTIVECAPTIONTEXT */
224 L"ButtonHilight", /* COLOR_BTNHIGHLIGHT */
225 L"ButtonDkShadow", /* COLOR_3DDKSHADOW */
226 L"ButtonLight", /* COLOR_3DLIGHT */
227 L"InfoText", /* COLOR_INFOTEXT */
228 L"InfoWindow", /* COLOR_INFOBK */
229 L"ButtonAlternateFace", /* COLOR_ALTERNATEBTNFACE */
230 L"HotTrackingColor", /* COLOR_HOTLIGHT */
231 L"GradientActiveTitle", /* COLOR_GRADIENTACTIVECAPTION */
232 L"GradientInactiveTitle", /* COLOR_GRADIENTINACTIVECAPTION */
233 L"MenuHilight", /* COLOR_MENUHILIGHT */
234 L"MenuBar", /* COLOR_MENUBAR */
237 static const WCHAR strColorKey[] = L"Control Panel\\Colors";
239 #define NUM_SYS_COLORS (COLOR_MENUBAR+1)
241 struct system_metrics
243 COLORREF system_colors[NUM_SYS_COLORS];
244 NONCLIENTMETRICSW non_client_metrics;
245 LOGFONTW icon_title_font;
246 DWORD gradient_caption;
247 DWORD flat_menu;
250 static BOOL UXTHEME_GetSystemMetrics(struct system_metrics *metrics)
252 DPI_AWARENESS_CONTEXT old_context;
253 BOOL ret = FALSE;
254 int i;
256 for (i = 0; i < NUM_SYS_COLORS; ++i)
257 metrics->system_colors[i] = GetSysColor(i);
259 old_context = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
261 memset(&metrics->non_client_metrics, 0, sizeof(metrics->non_client_metrics));
262 metrics->non_client_metrics.cbSize = sizeof(metrics->non_client_metrics);
263 if (!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(metrics->non_client_metrics),
264 &metrics->non_client_metrics, 0))
265 goto done;
266 memset(&metrics->icon_title_font, 0, sizeof(metrics->icon_title_font));
267 if (!SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(metrics->icon_title_font),
268 &metrics->icon_title_font, 0))
269 goto done;
270 if (!SystemParametersInfoW(SPI_GETGRADIENTCAPTIONS, 0, &metrics->gradient_caption, 0))
271 goto done;
272 if (!SystemParametersInfoW(SPI_GETFLATMENU, 0, &metrics->flat_menu, 0))
273 goto done;
275 ret = TRUE;
276 done:
277 SetThreadDpiAwarenessContext(old_context);
278 return ret;
281 /* Read back old settings after a theme was deactivated */
282 static BOOL UXTHEME_GetUnthemedSystemMetrics(struct system_metrics *metrics)
284 HKEY theme_manager_key = NULL, color_key = NULL;
285 BOOL ret = FALSE;
286 WCHAR string[13];
287 int i, r, g, b;
288 DWORD size;
290 if (RegOpenKeyExW(HKEY_CURRENT_USER, szThemeManager, 0, KEY_QUERY_VALUE, &theme_manager_key))
291 goto done;
293 if (RegOpenKeyExW(theme_manager_key, strColorKey, 0, KEY_QUERY_VALUE, &color_key))
294 goto done;
296 for (i = 0; i < NUM_SYS_COLORS; ++i)
298 size = sizeof(string);
299 if (RegQueryValueExW(color_key, SysColorsNames[i], 0, NULL, (BYTE *)string, &size))
300 goto done;
302 if (swscanf(string, L"%d %d %d", &r, &g, &b) != 3)
303 goto done;
305 metrics->system_colors[i] = RGB(r, g, b);
308 size = sizeof(metrics->non_client_metrics);
309 if (RegQueryValueExW(theme_manager_key, L"NonClientMetrics", 0, NULL,
310 (BYTE *)&metrics->non_client_metrics, &size))
311 goto done;
312 size = sizeof(metrics->icon_title_font);
313 if (RegQueryValueExW(theme_manager_key, L"IconTitleFont", 0, NULL,
314 (BYTE *)&metrics->icon_title_font, &size))
315 goto done;
316 size = sizeof(metrics->gradient_caption);
317 if (RegQueryValueExW(theme_manager_key, L"GradientCaption", 0, NULL,
318 (BYTE *)&metrics->gradient_caption, &size))
319 goto done;
320 size = sizeof(metrics->flat_menu);
321 if (RegQueryValueExW(theme_manager_key, L"FlatMenu", 0, NULL, (BYTE *)&metrics->flat_menu,
322 &size))
323 goto done;
325 ret = TRUE;
326 done:
327 RegCloseKey(color_key);
328 RegCloseKey(theme_manager_key);
329 return ret;
332 static void UXTHEME_SaveUnthemedSystemMetrics(struct system_metrics *metrics)
334 HKEY theme_manager_key, color_key;
335 WCHAR string[13];
336 DWORD length;
337 int i;
339 if (!RegCreateKeyExW(HKEY_CURRENT_USER, szThemeManager, 0, 0, 0, KEY_ALL_ACCESS, 0,
340 &theme_manager_key, 0))
342 if (!RegCreateKeyExW(theme_manager_key, strColorKey, 0, 0, 0, KEY_ALL_ACCESS, 0, &color_key,
345 for (i = 0; i < NUM_SYS_COLORS; ++i)
347 length = swprintf(string, ARRAY_SIZE(string), L"%d %d %d",
348 GetRValue(metrics->system_colors[i]),
349 GetGValue(metrics->system_colors[i]),
350 GetBValue(metrics->system_colors[i]));
351 RegSetValueExW(color_key, SysColorsNames[i], 0, REG_SZ, (BYTE *)string,
352 (length + 1) * sizeof(WCHAR));
355 RegCloseKey(color_key);
358 RegSetValueExW(theme_manager_key, L"NonClientMetrics", 0, REG_BINARY,
359 (BYTE *)&metrics->non_client_metrics, sizeof(metrics->non_client_metrics));
360 RegSetValueExW(theme_manager_key, L"IconTitleFont", 0, REG_BINARY,
361 (BYTE *)&metrics->icon_title_font, sizeof(metrics->icon_title_font));
362 RegSetValueExW(theme_manager_key, L"GradientCaption", 0, REG_DWORD,
363 (BYTE *)&metrics->gradient_caption, sizeof(metrics->gradient_caption));
364 RegSetValueExW(theme_manager_key, L"FlatMenu", 0, REG_DWORD, (BYTE *)&metrics->flat_menu,
365 sizeof(metrics->flat_menu));
366 RegCloseKey(theme_manager_key);
370 /* Make system settings persistent, so they're in effect even w/o uxtheme
371 * loaded.
372 * For efficiency reasons, only the last SystemParametersInfoW sets
373 * SPIF_SENDWININICHANGE */
374 static void UXTHEME_SaveSystemMetrics(struct system_metrics *metrics, BOOL send_syscolor_change)
376 int i, length, index[NUM_SYS_COLORS];
377 DPI_AWARENESS_CONTEXT old_context;
378 WCHAR string[13];
379 HKEY hkey;
381 if (!RegCreateKeyExW(HKEY_CURRENT_USER, strColorKey, 0, 0, 0, KEY_ALL_ACCESS, 0, &hkey, 0))
383 for (i = 0; i < NUM_SYS_COLORS; ++i)
385 length = swprintf(string, ARRAY_SIZE(string), L"%d %d %d",
386 GetRValue(metrics->system_colors[i]),
387 GetGValue(metrics->system_colors[i]),
388 GetBValue(metrics->system_colors[i]));
389 RegSetValueExW(hkey, SysColorsNames[i], 0, REG_SZ, (BYTE *)string,
390 (length + 1) * sizeof(WCHAR));
392 RegCloseKey(hkey);
395 if (send_syscolor_change)
397 for (i = 0; i < NUM_SYS_COLORS; ++i)
398 index[i] = i;
400 SetSysColors(NUM_SYS_COLORS, index, metrics->system_colors);
403 old_context = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
405 SystemParametersInfoW(SPI_SETNONCLIENTMETRICS, sizeof(metrics->non_client_metrics),
406 &metrics->non_client_metrics, SPIF_UPDATEINIFILE);
407 SystemParametersInfoW(SPI_SETICONTITLELOGFONT, sizeof(metrics->icon_title_font),
408 &metrics->icon_title_font, SPIF_UPDATEINIFILE);
409 SystemParametersInfoW(SPI_SETGRADIENTCAPTIONS, 0, (void *)(INT_PTR)metrics->gradient_caption,
410 SPIF_UPDATEINIFILE);
411 SystemParametersInfoW(SPI_SETFLATMENU, 0, (void *)(INT_PTR)metrics->flat_menu,
412 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
414 SetThreadDpiAwarenessContext(old_context);
417 /***********************************************************************
418 * UXTHEME_SetActiveTheme
420 * Change the current active theme
422 HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
424 BOOL ret, loaded_before = FALSE, same_theme = FALSE;
425 struct system_metrics metrics;
426 DWORD size;
427 HKEY hKey;
428 WCHAR tmp[2];
429 HRESULT hr;
431 if(tf) {
432 bThemeActive = TRUE;
433 same_theme = !lstrcmpW(szCurrentTheme, tf->szThemeFile)
434 && !lstrcmpW(szCurrentColor, tf->pszSelectedColor)
435 && !lstrcmpW(szCurrentSize, tf->pszSelectedSize);
436 lstrcpynW(szCurrentTheme, tf->szThemeFile, ARRAY_SIZE(szCurrentTheme));
437 lstrcpynW(szCurrentColor, tf->pszSelectedColor, ARRAY_SIZE(szCurrentColor));
438 lstrcpynW(szCurrentSize, tf->pszSelectedSize, ARRAY_SIZE(szCurrentSize));
440 ret = UXTHEME_GetSystemMetrics(&metrics);
442 /* Check if theming is already active */
443 if (!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey))
445 size = sizeof(tmp);
446 if (!RegQueryValueExW(hKey, L"LoadedBefore", NULL, NULL, (BYTE *)tmp, &size))
447 loaded_before = (tmp[0] != '0');
448 else
449 WARN("Failed to get LoadedBefore: %ld\n", GetLastError());
450 RegCloseKey(hKey);
452 if (loaded_before && same_theme)
453 return MSSTYLES_SetActiveTheme(tf, FALSE);
455 if (!loaded_before && ret)
456 UXTHEME_SaveUnthemedSystemMetrics(&metrics);
458 else {
459 bThemeActive = FALSE;
460 szCurrentTheme[0] = '\0';
461 szCurrentColor[0] = '\0';
462 szCurrentSize[0] = '\0';
465 TRACE("Writing theme config to registry\n");
466 if(!RegCreateKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
467 tmp[0] = bThemeActive?'1':'0';
468 tmp[1] = '\0';
469 RegSetValueExW(hKey, L"ThemeActive", 0, REG_SZ, (const BYTE*)tmp, sizeof(WCHAR)*2);
470 if(bThemeActive) {
471 RegSetValueExW(hKey, L"ColorName", 0, REG_SZ, (const BYTE*)szCurrentColor,
472 (lstrlenW(szCurrentColor)+1)*sizeof(WCHAR));
473 RegSetValueExW(hKey, L"SizeName", 0, REG_SZ, (const BYTE*)szCurrentSize,
474 (lstrlenW(szCurrentSize)+1)*sizeof(WCHAR));
475 RegSetValueExW(hKey, L"DllName", 0, REG_SZ, (const BYTE*)szCurrentTheme,
476 (lstrlenW(szCurrentTheme)+1)*sizeof(WCHAR));
477 RegSetValueExW(hKey, L"LoadedBefore", 0, REG_SZ, (const BYTE *)tmp, sizeof(WCHAR) * 2);
479 else {
480 RegDeleteValueW(hKey, L"ColorName");
481 RegDeleteValueW(hKey, L"SizeName");
482 RegDeleteValueW(hKey, L"DllName");
483 RegDeleteValueW(hKey, L"LoadedBefore");
485 RegCloseKey(hKey);
487 else
488 TRACE("Failed to open theme registry key\n");
490 hr = MSSTYLES_SetActiveTheme(tf, TRUE);
491 if (bThemeActive)
493 if (UXTHEME_GetSystemMetrics(&metrics))
494 UXTHEME_SaveSystemMetrics(&metrics, FALSE);
496 else
498 if (UXTHEME_GetUnthemedSystemMetrics(&metrics))
499 UXTHEME_SaveSystemMetrics(&metrics, TRUE);
501 return hr;
504 /***********************************************************************
505 * UXTHEME_InitSystem
507 void UXTHEME_InitSystem(HINSTANCE hInst)
509 atWindowTheme = GlobalAddAtomW(L"ux_theme");
510 atSubAppName = GlobalAddAtomW(L"ux_subapp");
511 atSubIdList = GlobalAddAtomW(L"ux_subidlst");
512 atDialogThemeEnabled = GlobalAddAtomW(L"ux_dialogtheme");
514 UXTHEME_LoadTheme();
515 ThemeHooksInstall();
518 void UXTHEME_UninitSystem(void)
520 ThemeHooksRemove();
521 MSSTYLES_SetActiveTheme(NULL, FALSE);
523 GlobalDeleteAtom(atWindowTheme);
524 GlobalDeleteAtom(atSubAppName);
525 GlobalDeleteAtom(atSubIdList);
526 GlobalDeleteAtom(atDialogThemeEnabled);
529 /***********************************************************************
530 * IsAppThemed (UXTHEME.@)
532 BOOL WINAPI IsAppThemed(void)
534 return IsThemeActive();
537 /***********************************************************************
538 * IsThemeActive (UXTHEME.@)
540 BOOL WINAPI IsThemeActive(void)
542 TRACE("\n");
543 SetLastError(ERROR_SUCCESS);
544 return bThemeActive;
547 /************************************************************
548 * IsCompositionActive (UXTHEME.@)
550 BOOL WINAPI IsCompositionActive(void)
552 FIXME(": stub\n");
554 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
556 return FALSE;
559 /***********************************************************************
560 * EnableTheming (UXTHEME.@)
562 * NOTES
563 * This is a global and persistent change
565 HRESULT WINAPI EnableTheming(BOOL fEnable)
567 HKEY hKey;
569 TRACE("(%d)\n", fEnable);
571 if (bThemeActive && !fEnable)
573 bThemeActive = fEnable;
574 if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
575 RegSetValueExW(hKey, L"ThemeActive", 0, REG_SZ, (BYTE *)L"0", 2 * sizeof(WCHAR));
576 RegCloseKey(hKey);
578 UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
580 return S_OK;
583 /***********************************************************************
584 * UXTHEME_SetWindowProperty
586 * I'm using atoms as there may be large numbers of duplicated strings
587 * and they do the work of keeping memory down as a cause of that quite nicely
589 static HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue)
591 ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
592 if(oldValue)
593 DeleteAtom(oldValue);
594 if(pszValue) {
595 ATOM atValue = AddAtomW(pszValue);
596 if(!atValue
597 || !SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp), (LPWSTR)MAKEINTATOM(atValue))) {
598 HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
599 if(atValue) DeleteAtom(atValue);
600 return hr;
603 return S_OK;
606 static LPWSTR UXTHEME_GetWindowProperty(HWND hwnd, ATOM aProp, LPWSTR pszBuffer, int dwLen)
608 ATOM atValue = (ATOM)(size_t)GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
609 if(atValue) {
610 if(GetAtomNameW(atValue, pszBuffer, dwLen))
611 return pszBuffer;
612 TRACE("property defined, but unable to get value\n");
614 return NULL;
617 static HTHEME open_theme_data(HWND hwnd, LPCWSTR pszClassList, DWORD flags, UINT dpi)
619 WCHAR szAppBuff[256];
620 WCHAR szClassBuff[256];
621 LPCWSTR pszAppName;
622 LPCWSTR pszUseClassList;
623 HTHEME hTheme = NULL;
624 TRACE("(%p,%s, %lx)\n", hwnd, debugstr_w(pszClassList), flags);
626 if(!pszClassList)
628 SetLastError(E_POINTER);
629 return NULL;
632 if(flags)
633 FIXME("unhandled flags: %lx\n", flags);
635 if(bThemeActive)
637 pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, ARRAY_SIZE(szAppBuff));
638 /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */
639 pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, ARRAY_SIZE(szClassBuff));
640 if(!pszUseClassList)
641 pszUseClassList = pszClassList;
643 if (pszUseClassList)
644 hTheme = MSSTYLES_OpenThemeClass(pszAppName, pszUseClassList, dpi);
646 /* Fall back to default class if the specified subclass is not found */
647 if (!hTheme)
648 hTheme = MSSTYLES_OpenThemeClass(NULL, pszUseClassList, dpi);
650 if(IsWindow(hwnd))
651 SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme), hTheme);
652 TRACE(" = %p\n", hTheme);
654 SetLastError(hTheme ? ERROR_SUCCESS : E_PROP_ID_UNSUPPORTED);
655 return hTheme;
658 /***********************************************************************
659 * OpenThemeDataEx (UXTHEME.61)
661 HTHEME WINAPI OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD flags)
663 UINT dpi;
665 dpi = GetDpiForWindow(hwnd);
666 if (!dpi)
667 dpi = 96;
669 return open_theme_data(hwnd, pszClassList, flags, dpi);
672 /***********************************************************************
673 * OpenThemeDataForDpi (UXTHEME.@)
675 HTHEME WINAPI OpenThemeDataForDpi(HWND hwnd, LPCWSTR class_list, UINT dpi)
677 return open_theme_data(hwnd, class_list, 0, dpi);
680 /***********************************************************************
681 * OpenThemeData (UXTHEME.@)
683 HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
685 return OpenThemeDataEx(hwnd, classlist, 0);
688 /***********************************************************************
689 * GetWindowTheme (UXTHEME.@)
691 * Retrieve the last theme opened for a window.
693 * PARAMS
694 * hwnd [I] window to retrieve the theme for
696 * RETURNS
697 * The most recent theme.
699 HTHEME WINAPI GetWindowTheme(HWND hwnd)
701 TRACE("(%p)\n", hwnd);
703 if (!hwnd)
705 SetLastError(E_HANDLE);
706 return NULL;
709 return GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme));
712 /***********************************************************************
713 * SetWindowTheme (UXTHEME.@)
715 * Persistent through the life of the window, even after themes change
717 HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
718 LPCWSTR pszSubIdList)
720 HRESULT hr;
721 TRACE("(%p,%s,%s)\n", hwnd, debugstr_w(pszSubAppName),
722 debugstr_w(pszSubIdList));
724 if (!hwnd)
725 return E_HANDLE;
727 hr = UXTHEME_SetWindowProperty(hwnd, atSubAppName, pszSubAppName);
728 if(SUCCEEDED(hr))
729 hr = UXTHEME_SetWindowProperty(hwnd, atSubIdList, pszSubIdList);
730 if(SUCCEEDED(hr))
731 SendMessageW(hwnd, WM_THEMECHANGED, 0, 0);
732 return hr;
735 /***********************************************************************
736 * SetWindowThemeAttribute (UXTHEME.@)
738 HRESULT WINAPI SetWindowThemeAttribute(HWND hwnd, enum WINDOWTHEMEATTRIBUTETYPE type,
739 PVOID attribute, DWORD size)
741 FIXME("(%p,%d,%p,%ld): stub\n", hwnd, type, attribute, size);
742 return E_NOTIMPL;
745 /***********************************************************************
746 * GetCurrentThemeName (UXTHEME.@)
748 HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars,
749 LPWSTR pszColorBuff, int cchMaxColorChars,
750 LPWSTR pszSizeBuff, int cchMaxSizeChars)
752 if(!bThemeActive)
753 return E_PROP_ID_UNSUPPORTED;
754 if(pszThemeFileName) lstrcpynW(pszThemeFileName, szCurrentTheme, dwMaxNameChars);
755 if(pszColorBuff) lstrcpynW(pszColorBuff, szCurrentColor, cchMaxColorChars);
756 if(pszSizeBuff) lstrcpynW(pszSizeBuff, szCurrentSize, cchMaxSizeChars);
757 return S_OK;
760 /***********************************************************************
761 * GetThemeAppProperties (UXTHEME.@)
763 DWORD WINAPI GetThemeAppProperties(void)
765 return dwThemeAppProperties;
768 /***********************************************************************
769 * SetThemeAppProperties (UXTHEME.@)
771 void WINAPI SetThemeAppProperties(DWORD dwFlags)
773 TRACE("(0x%08lx)\n", dwFlags);
774 dwThemeAppProperties = dwFlags;
777 /***********************************************************************
778 * CloseThemeData (UXTHEME.@)
780 HRESULT WINAPI CloseThemeData(HTHEME hTheme)
782 TRACE("(%p)\n", hTheme);
783 if(!hTheme || hTheme == INVALID_HANDLE_VALUE)
784 return E_HANDLE;
785 return MSSTYLES_CloseThemeClass(hTheme);
788 /***********************************************************************
789 * HitTestThemeBackground (UXTHEME.@)
791 HRESULT WINAPI HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId,
792 int iStateId, DWORD dwOptions,
793 const RECT *pRect, HRGN hrgn,
794 POINT ptTest, WORD *pwHitTestCode)
796 FIXME("%d %d 0x%08lx: stub\n", iPartId, iStateId, dwOptions);
797 if(!hTheme)
798 return E_HANDLE;
799 return E_NOTIMPL;
802 /***********************************************************************
803 * IsThemePartDefined (UXTHEME.@)
805 BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId)
807 TRACE("(%p,%d,%d)\n", hTheme, iPartId, iStateId);
808 if(!hTheme) {
809 SetLastError(E_HANDLE);
810 return FALSE;
813 SetLastError(NO_ERROR);
814 return !iStateId && MSSTYLES_FindPart(hTheme, iPartId);
817 /***********************************************************************
818 * GetThemeDocumentationProperty (UXTHEME.@)
820 * Try and retrieve the documentation property from string resources
821 * if that fails, get it from the [documentation] section of themes.ini
823 HRESULT WINAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName,
824 LPCWSTR pszPropertyName,
825 LPWSTR pszValueBuff,
826 int cchMaxValChars)
828 static const WORD wDocToRes[] = {
829 TMT_DISPLAYNAME,5000,
830 TMT_TOOLTIP,5001,
831 TMT_COMPANY,5002,
832 TMT_AUTHOR,5003,
833 TMT_COPYRIGHT,5004,
834 TMT_URL,5005,
835 TMT_VERSION,5006,
836 TMT_DESCRIPTION,5007
839 PTHEME_FILE pt;
840 HRESULT hr;
841 unsigned int i;
842 int iDocId;
843 TRACE("(%s,%s,%p,%d)\n", debugstr_w(pszThemeName), debugstr_w(pszPropertyName),
844 pszValueBuff, cchMaxValChars);
846 hr = MSSTYLES_OpenThemeFile(pszThemeName, NULL, NULL, &pt);
847 if(FAILED(hr)) return hr;
849 /* Try to load from string resources */
850 hr = E_PROP_ID_UNSUPPORTED;
851 if(MSSTYLES_LookupProperty(pszPropertyName, NULL, &iDocId)) {
852 for(i=0; i<ARRAY_SIZE(wDocToRes); i+=2) {
853 if(wDocToRes[i] == iDocId) {
854 if(LoadStringW(pt->hTheme, wDocToRes[i+1], pszValueBuff, cchMaxValChars)) {
855 hr = S_OK;
856 break;
861 /* If loading from string resource failed, try getting it from the theme.ini */
862 if(FAILED(hr)) {
863 PUXINI_FILE uf = MSSTYLES_GetThemeIni(pt);
864 if(UXINI_FindSection(uf, L"documentation")) {
865 LPCWSTR lpValue;
866 DWORD dwLen;
867 if(UXINI_FindValue(uf, pszPropertyName, &lpValue, &dwLen)) {
868 lstrcpynW(pszValueBuff, lpValue, min(dwLen+1,cchMaxValChars));
869 hr = S_OK;
872 UXINI_CloseINI(uf);
875 MSSTYLES_CloseThemeFile(pt);
876 return hr;
879 /**********************************************************************
880 * Undocumented functions
883 /**********************************************************************
884 * QueryThemeServices (UXTHEME.1)
886 * RETURNS
887 * some kind of status flag
889 DWORD WINAPI QueryThemeServices(void)
891 FIXME("stub\n");
892 return 3; /* This is what is returned under XP in most cases */
896 /**********************************************************************
897 * OpenThemeFile (UXTHEME.2)
899 * Opens a theme file, which can be used to change the current theme, etc
901 * PARAMS
902 * pszThemeFileName Path to a msstyles theme file
903 * pszColorName Color defined in the theme, eg. NormalColor
904 * pszSizeName Size defined in the theme, eg. NormalSize
905 * hThemeFile Handle to theme file
907 * RETURNS
908 * Success: S_OK
909 * Failure: HRESULT error-code
911 HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName,
912 LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile,
913 DWORD unknown)
915 TRACE("(%s,%s,%s,%p,%ld)\n", debugstr_w(pszThemeFileName),
916 debugstr_w(pszColorName), debugstr_w(pszSizeName),
917 hThemeFile, unknown);
918 return MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, (PTHEME_FILE*)hThemeFile);
921 /**********************************************************************
922 * CloseThemeFile (UXTHEME.3)
924 * Releases theme file handle returned by OpenThemeFile
926 * PARAMS
927 * hThemeFile Handle to theme file
929 * RETURNS
930 * Success: S_OK
931 * Failure: HRESULT error-code
933 HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile)
935 TRACE("(%p)\n", hThemeFile);
936 MSSTYLES_CloseThemeFile(hThemeFile);
937 return S_OK;
940 /**********************************************************************
941 * ApplyTheme (UXTHEME.4)
943 * Set a theme file to be the currently active theme
945 * PARAMS
946 * hThemeFile Handle to theme file
947 * unknown See notes
948 * hWnd Window requesting the theme change
950 * RETURNS
951 * Success: S_OK
952 * Failure: HRESULT error-code
954 * NOTES
955 * I'm not sure what the second parameter is (the datatype is likely wrong), other then this:
956 * Under XP if I pass
957 * char b[] = "";
958 * the theme is applied with the screen redrawing really badly (flickers)
959 * char b[] = "\0"; where \0 can be one or more of any character, makes no difference
960 * the theme is applied smoothly (screen does not flicker)
961 * char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference
962 * the function fails returning invalid parameter... very strange
964 HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd)
966 HRESULT hr;
967 TRACE("(%p,%s,%p)\n", hThemeFile, unknown, hWnd);
968 hr = UXTHEME_SetActiveTheme(hThemeFile);
969 UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
970 return hr;
973 /**********************************************************************
974 * GetThemeDefaults (UXTHEME.7)
976 * Get the default color & size for a theme
978 * PARAMS
979 * pszThemeFileName Path to a msstyles theme file
980 * pszColorName Buffer to receive the default color name
981 * dwColorNameLen Length, in characters, of color name buffer
982 * pszSizeName Buffer to receive the default size name
983 * dwSizeNameLen Length, in characters, of size name buffer
985 * RETURNS
986 * Success: S_OK
987 * Failure: HRESULT error-code
989 HRESULT WINAPI GetThemeDefaults(LPCWSTR pszThemeFileName, LPWSTR pszColorName,
990 DWORD dwColorNameLen, LPWSTR pszSizeName,
991 DWORD dwSizeNameLen)
993 PTHEME_FILE pt;
994 HRESULT hr;
995 TRACE("(%s,%p,%ld,%p,%ld)\n", debugstr_w(pszThemeFileName),
996 pszColorName, dwColorNameLen,
997 pszSizeName, dwSizeNameLen);
999 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
1000 if(FAILED(hr)) return hr;
1002 lstrcpynW(pszColorName, pt->pszSelectedColor, dwColorNameLen);
1003 lstrcpynW(pszSizeName, pt->pszSelectedSize, dwSizeNameLen);
1005 MSSTYLES_CloseThemeFile(pt);
1006 return S_OK;
1009 /**********************************************************************
1010 * EnumThemes (UXTHEME.8)
1012 * Enumerate available themes, calls specified EnumThemeProc for each
1013 * theme found. Passes lpData through to callback function.
1015 * PARAMS
1016 * pszThemePath Path containing themes
1017 * callback Called for each theme found in path
1018 * lpData Passed through to callback
1020 * RETURNS
1021 * Success: S_OK
1022 * Failure: HRESULT error-code
1024 HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, EnumThemeProc callback,
1025 LPVOID lpData)
1027 WCHAR szDir[MAX_PATH];
1028 WCHAR szPath[MAX_PATH];
1029 WCHAR szName[60];
1030 WCHAR szTip[60];
1031 HANDLE hFind;
1032 WIN32_FIND_DATAW wfd;
1033 HRESULT hr;
1034 size_t pathLen;
1036 TRACE("(%s,%p,%p)\n", debugstr_w(pszThemePath), callback, lpData);
1038 if(!pszThemePath || !callback)
1039 return E_POINTER;
1041 lstrcpyW(szDir, pszThemePath);
1042 pathLen = lstrlenW (szDir);
1043 if ((pathLen > 0) && (pathLen < MAX_PATH-1) && (szDir[pathLen - 1] != '\\'))
1045 szDir[pathLen] = '\\';
1046 szDir[pathLen+1] = 0;
1049 lstrcpyW(szPath, szDir);
1050 lstrcatW(szPath, L"*.*");
1051 TRACE("searching %s\n", debugstr_w(szPath));
1053 hFind = FindFirstFileW(szPath, &wfd);
1054 if(hFind != INVALID_HANDLE_VALUE) {
1055 do {
1056 if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
1057 && !(wfd.cFileName[0] == '.' && ((wfd.cFileName[1] == '.' && wfd.cFileName[2] == 0) || wfd.cFileName[1] == 0))) {
1058 wsprintfW(szPath, L"%s%s\\%s.msstyles", szDir, wfd.cFileName, wfd.cFileName);
1060 hr = GetThemeDocumentationProperty(szPath, L"displayname", szName, ARRAY_SIZE(szName));
1061 if(SUCCEEDED(hr))
1062 hr = GetThemeDocumentationProperty(szPath, L"tooltip", szTip, ARRAY_SIZE(szTip));
1063 if(SUCCEEDED(hr)) {
1064 TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath), debugstr_w(szName), debugstr_w(szTip), lpData);
1065 if(!callback(NULL, szPath, szName, szTip, NULL, lpData)) {
1066 TRACE("callback ended enum\n");
1067 break;
1071 } while(FindNextFileW(hFind, &wfd));
1072 FindClose(hFind);
1074 return S_OK;
1078 /**********************************************************************
1079 * EnumThemeColors (UXTHEME.9)
1081 * Enumerate theme colors available with a particular size
1083 * PARAMS
1084 * pszThemeFileName Path to a msstyles theme file
1085 * pszSizeName Theme size to enumerate available colors
1086 * If NULL the default theme size is used
1087 * dwColorNum Color index to retrieve, increment from 0
1088 * pszColorNames Output color names
1090 * RETURNS
1091 * S_OK on success
1092 * E_PROP_ID_UNSUPPORTED when dwColorName does not refer to a color
1093 * or when pszSizeName does not refer to a valid size
1095 * NOTES
1096 * XP fails with E_POINTER when pszColorNames points to a buffer smaller than
1097 * sizeof(THEMENAMES).
1099 * Not very efficient that I'm opening & validating the theme every call, but
1100 * this is undocumented and almost never called..
1101 * (and this is how windows works too)
1103 HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName,
1104 DWORD dwColorNum, PTHEMENAMES pszColorNames)
1106 PTHEME_FILE pt;
1107 HRESULT hr;
1108 LPWSTR tmp;
1109 UINT resourceId = dwColorNum + 1000;
1110 TRACE("(%s,%s,%ld)\n", debugstr_w(pszThemeFileName),
1111 debugstr_w(pszSizeName), dwColorNum);
1113 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, pszSizeName, &pt);
1114 if(FAILED(hr)) return hr;
1116 tmp = pt->pszAvailColors;
1117 while(dwColorNum && *tmp) {
1118 dwColorNum--;
1119 tmp += lstrlenW(tmp)+1;
1121 if(!dwColorNum && *tmp) {
1122 TRACE("%s\n", debugstr_w(tmp));
1123 lstrcpyW(pszColorNames->szName, tmp);
1124 LoadStringW(pt->hTheme, resourceId, pszColorNames->szDisplayName,
1125 ARRAY_SIZE(pszColorNames->szDisplayName));
1126 LoadStringW(pt->hTheme, resourceId+1000, pszColorNames->szTooltip,
1127 ARRAY_SIZE(pszColorNames->szTooltip));
1129 else
1130 hr = E_PROP_ID_UNSUPPORTED;
1132 MSSTYLES_CloseThemeFile(pt);
1133 return hr;
1136 /**********************************************************************
1137 * EnumThemeSizes (UXTHEME.10)
1139 * Enumerate theme colors available with a particular size
1141 * PARAMS
1142 * pszThemeFileName Path to a msstyles theme file
1143 * pszColorName Theme color to enumerate available sizes
1144 * If NULL the default theme color is used
1145 * dwSizeNum Size index to retrieve, increment from 0
1146 * pszSizeNames Output size names
1148 * RETURNS
1149 * S_OK on success
1150 * E_PROP_ID_UNSUPPORTED when dwSizeName does not refer to a size
1151 * or when pszColorName does not refer to a valid color
1153 * NOTES
1154 * XP fails with E_POINTER when pszSizeNames points to a buffer smaller than
1155 * sizeof(THEMENAMES).
1157 * Not very efficient that I'm opening & validating the theme every call, but
1158 * this is undocumented and almost never called..
1159 * (and this is how windows works too)
1161 HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName,
1162 DWORD dwSizeNum, PTHEMENAMES pszSizeNames)
1164 PTHEME_FILE pt;
1165 HRESULT hr;
1166 LPWSTR tmp;
1167 UINT resourceId = dwSizeNum + 3000;
1168 TRACE("(%s,%s,%ld)\n", debugstr_w(pszThemeFileName),
1169 debugstr_w(pszColorName), dwSizeNum);
1171 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, NULL, &pt);
1172 if(FAILED(hr)) return hr;
1174 tmp = pt->pszAvailSizes;
1175 while(dwSizeNum && *tmp) {
1176 dwSizeNum--;
1177 tmp += lstrlenW(tmp)+1;
1179 if(!dwSizeNum && *tmp) {
1180 TRACE("%s\n", debugstr_w(tmp));
1181 lstrcpyW(pszSizeNames->szName, tmp);
1182 LoadStringW(pt->hTheme, resourceId, pszSizeNames->szDisplayName,
1183 ARRAY_SIZE(pszSizeNames->szDisplayName));
1184 LoadStringW(pt->hTheme, resourceId+1000, pszSizeNames->szTooltip,
1185 ARRAY_SIZE(pszSizeNames->szTooltip));
1187 else
1188 hr = E_PROP_ID_UNSUPPORTED;
1190 MSSTYLES_CloseThemeFile(pt);
1191 return hr;
1194 /**********************************************************************
1195 * ParseThemeIniFile (UXTHEME.11)
1197 * Enumerate data in a theme INI file.
1199 * PARAMS
1200 * pszIniFileName Path to a theme ini file
1201 * pszUnknown Cannot be NULL, L"" is valid
1202 * callback Called for each found entry
1203 * lpData Passed through to callback
1205 * RETURNS
1206 * S_OK on success
1207 * 0x800706488 (Unknown property) when enumeration is canceled from callback
1209 * NOTES
1210 * When pszUnknown is NULL the callback is never called, the value does not seem to serve
1211 * any other purpose
1213 HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
1214 ParseThemeIniFileProc callback, LPVOID lpData)
1216 FIXME("%s %s: stub\n", debugstr_w(pszIniFileName), debugstr_w(pszUnknown));
1217 return E_NOTIMPL;
1220 /**********************************************************************
1221 * CheckThemeSignature (UXTHEME.29)
1223 * Validates the signature of a theme file
1225 * PARAMS
1226 * pszIniFileName Path to a theme file
1228 * RETURNS
1229 * Success: S_OK
1230 * Failure: HRESULT error-code
1232 HRESULT WINAPI CheckThemeSignature(LPCWSTR pszThemeFileName)
1234 PTHEME_FILE pt;
1235 HRESULT hr;
1236 TRACE("(%s)\n", debugstr_w(pszThemeFileName));
1237 hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
1238 if(FAILED(hr))
1239 return hr;
1240 MSSTYLES_CloseThemeFile(pt);
1241 return S_OK;
1244 BOOL WINAPI ThemeHooksInstall(void)
1246 struct user_api_hook hooks;
1248 hooks.pDefDlgProc = UXTHEME_DefDlgProc;
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;