From a7d4b8d04f9dedafde806774e91710def93baf2b Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sat, 25 Feb 2017 09:23:37 +0000 Subject: [PATCH] [UXTHEME] - When we set the desired app name and class name in SetWindowTheme we need to support empty strings meaning no themes for this window. Sort of support empty strings by replacing them with a string containing a single "0". This works since there is no app name or class name with this name. Also add some error messages. svn path=/trunk/; revision=73898 --- reactos/dll/win32/uxtheme/system.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/uxtheme/system.c b/reactos/dll/win32/uxtheme/system.c index 9624b33510a..86fbc9840f4 100644 --- a/reactos/dll/win32/uxtheme/system.c +++ b/reactos/dll/win32/uxtheme/system.c @@ -667,14 +667,31 @@ static HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue { ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp)); if(oldValue) + { DeleteAtom(oldValue); - if(pszValue) { - ATOM atValue = AddAtomW(pszValue); - if(!atValue - || !SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp), (LPWSTR)MAKEINTATOM(atValue))) { - HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); + } + + if(pszValue) + { + ATOM atValue; + + /* A string with zero lenght is not acceptatble in AddAtomW but we want to support + users passing an empty string meaning they want no theme for the specified window */ + if(!pszValue[0]) + pszValue = L"0"; + + atValue = AddAtomW(pszValue); + if (!atValue) + { + ERR("AddAtomW for %S failed with last error %d!\n", pszValue, GetLastError()); + return HRESULT_FROM_WIN32(GetLastError()); + } + + if (!SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp), (LPWSTR)MAKEINTATOM(atValue))) + { + ERR("SetPropW for atom %d failed with last error %d\n", aProp, GetLastError()); if(atValue) DeleteAtom(atValue); - return hr; + return HRESULT_FROM_WIN32(GetLastError()); } } return S_OK;