/*********************************************************************** * UXTHEME_LoadTheme * * Set the current active theme from the registry */ static void UXTHEME_LoadTheme(void) { HKEY hKey; DWORD buffsize; HRESULT hr; WCHAR tmp[10]; PTHEME_FILE pt; /* Get current theme configuration */ if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) { TRACE("Loading theme config\n"); buffsize = sizeof(tmp)/sizeof(tmp[0]); if(!RegQueryValueExW(hKey, szThemeActive, NULL, NULL, (LPBYTE)tmp, &buffsize)) { bThemeActive = (tmp[0] != '0'); } else { bThemeActive = FALSE; TRACE("Failed to get ThemeActive: %d\n", GetLastError()); } buffsize = sizeof(szCurrentColor)/sizeof(szCurrentColor[0]); if(RegQueryValueExW(hKey, szColorName, NULL, NULL, (LPBYTE)szCurrentColor, &buffsize)) szCurrentColor[0] = '\0'; buffsize = sizeof(szCurrentSize)/sizeof(szCurrentSize[0]); if(RegQueryValueExW(hKey, szSizeName, NULL, NULL, (LPBYTE)szCurrentSize, &buffsize)) szCurrentSize[0] = '\0'; if (query_reg_path (hKey, szDllName, szCurrentTheme)) szCurrentTheme[0] = '\0'; RegCloseKey(hKey); } else TRACE("Failed to open theme registry key\n"); if(bThemeActive) { /* Make sure the theme requested is actually valid */ hr = MSSTYLES_OpenThemeFile(szCurrentTheme, szCurrentColor[0]?szCurrentColor:NULL, szCurrentSize[0]?szCurrentSize:NULL, &pt); if(FAILED(hr)) { bThemeActive = FALSE; szCurrentTheme[0] = '\0'; szCurrentColor[0] = '\0'; szCurrentSize[0] = '\0'; } else { /* Make sure the global color & size match the theme */ lstrcpynW(szCurrentColor, pt->pszSelectedColor, sizeof(szCurrentColor)/sizeof(szCurrentColor[0])); lstrcpynW(szCurrentSize, pt->pszSelectedSize, sizeof(szCurrentSize)/sizeof(szCurrentSize[0])); MSSTYLES_SetActiveTheme(pt, FALSE); TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme), debugstr_w(szCurrentColor), debugstr_w(szCurrentSize)); MSSTYLES_CloseThemeFile(pt); } } if(!bThemeActive) { MSSTYLES_SetActiveTheme(NULL, FALSE); TRACE("Theming not active\n"); } }
/*********************************************************************** * UXTHEME_LoadTheme * * Set the current active theme from the registry */ void UXTHEME_LoadTheme(BOOL bLoad) { HKEY hKey; DWORD buffsize; HRESULT hr; WCHAR tmp[10]; PTHEME_FILE pt; WCHAR szCurrentTheme[MAX_PATH]; WCHAR szCurrentColor[64]; WCHAR szCurrentSize[64]; BOOL bThemeActive = FALSE; if(bLoad == TRUE) { /* Get current theme configuration */ if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) { TRACE("Loading theme config\n"); buffsize = sizeof(tmp)/sizeof(tmp[0]); if(!RegQueryValueExW(hKey, szThemeActive, NULL, NULL, (LPBYTE)tmp, &buffsize)) { bThemeActive = (tmp[0] != '0'); } else { bThemeActive = FALSE; TRACE("Failed to get ThemeActive: %d\n", GetLastError()); } buffsize = sizeof(szCurrentColor)/sizeof(szCurrentColor[0]); if(RegQueryValueExW(hKey, szColorName, NULL, NULL, (LPBYTE)szCurrentColor, &buffsize)) szCurrentColor[0] = '\0'; buffsize = sizeof(szCurrentSize)/sizeof(szCurrentSize[0]); if(RegQueryValueExW(hKey, szSizeName, NULL, NULL, (LPBYTE)szCurrentSize, &buffsize)) szCurrentSize[0] = '\0'; if (query_reg_path (hKey, szDllName, szCurrentTheme)) szCurrentTheme[0] = '\0'; RegCloseKey(hKey); } else TRACE("Failed to open theme registry key\n"); } else { bThemeActive = FALSE; } if(bThemeActive) { if( bIsThemeActive(szCurrentTheme, szCurrentColor, szCurrentSize) ) { TRACE("Tried to load active theme again\n"); return; } /* Make sure the theme requested is actually valid */ hr = MSSTYLES_OpenThemeFile(szCurrentTheme, szCurrentColor[0]?szCurrentColor:NULL, szCurrentSize[0]?szCurrentSize:NULL, &pt); if(FAILED(hr)) { bThemeActive = FALSE; } else { TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme), debugstr_w(szCurrentColor), debugstr_w(szCurrentSize)); UXTHEME_SetActiveTheme(pt); MSSTYLES_CloseThemeFile(pt); } } if(!bThemeActive) { UXTHEME_SetActiveTheme(NULL); TRACE("Theming not active\n"); } }