{
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;