From 100923508c8f6042a3331795b24fd277187b2453 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Sun, 24 Jul 2005 17:11:05 +0000 Subject: [PATCH] OpenThemeData() now always sets the window theme to the handle returned (even if that is NULL) - previously, it could happen that when no theme was active or the theme data could not be opened that the window theme remained became then-dangling (and hence subsequent calls to GetWindowTheme() would return that bogus theme). --- dlls/uxtheme/system.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/dlls/uxtheme/system.c b/dlls/uxtheme/system.c index 5d10dc7710a..2a5837f0f07 100644 --- a/dlls/uxtheme/system.c +++ b/dlls/uxtheme/system.c @@ -324,22 +324,23 @@ HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR pszClassList) WCHAR szClassBuff[256]; LPCWSTR pszAppName; LPCWSTR pszUseClassList; - HTHEME hTheme; - TRACE("(%p,%s)\n", hwnd, debugstr_w(pszClassList)); - if(!bThemeActive) - return NULL; + HTHEME hTheme = NULL; + TRACE("(%p,%s)", hwnd, debugstr_w(pszClassList)); - pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, sizeof(szAppBuff)/sizeof(szAppBuff[0])); - /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */ - pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, sizeof(szClassBuff)/sizeof(szClassBuff[0])); - if(!pszUseClassList) - pszUseClassList = pszClassList; + if(bThemeActive) + { + pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, sizeof(szAppBuff)/sizeof(szAppBuff[0])); + /* If SetWindowTheme was used on the window, that overrides the class list passed to this function */ + pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, sizeof(szClassBuff)/sizeof(szClassBuff[0])); + if(!pszUseClassList) + pszUseClassList = pszClassList; - if (!pszClassList) return NULL; - - hTheme = MSSTYLES_OpenThemeClass(pszAppName, pszUseClassList); + if (pszUseClassList) + hTheme = MSSTYLES_OpenThemeClass(pszAppName, pszUseClassList); + } if(IsWindow(hwnd)) SetPropW(hwnd, MAKEINTATOMW(atWindowTheme), hTheme); + TRACE(" = %p\n", hTheme); return hTheme; }