/********************************************************************** * ApplyTheme (UXTHEME.4) * * Set a theme file to be the currently active theme * * PARAMS * hThemeFile Handle to theme file * unknown See notes * hWnd Window requesting the theme change * * RETURNS * Success: S_OK * Failure: HRESULT error-code * * NOTES * I'm not sure what the second parameter is (the datatype is likely wrong), other then this: * Under XP if I pass * char b[] = ""; * the theme is applied with the screen redrawing really badly (flickers) * char b[] = "\0"; where \0 can be one or more of any character, makes no difference * the theme is applied smoothly (screen does not flicker) * char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference * the function fails returning invalid parameter... very strange */ HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd) { HRESULT hr; TRACE("(%p,%s,%p)\n", hThemeFile, unknown, hWnd); hr = UXTHEME_ApplyTheme(hThemeFile); UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED); return hr; }
BOOL WINAPI ThemeHooksRemove() { BOOL ret; ret = UnregisterUserApiHook(); UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED); return ret; }
/*********************************************************************** * SetWindowTheme (UXTHEME.@) * * Persistent through the life of the window, even after themes change */ HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList) { HRESULT hr; TRACE("(%p,%s,%s)\n", hwnd, debugstr_w(pszSubAppName), debugstr_w(pszSubIdList)); hr = UXTHEME_SetWindowProperty(hwnd, atSubAppName, pszSubAppName); if(SUCCEEDED(hr)) hr = UXTHEME_SetWindowProperty(hwnd, atSubIdList, pszSubIdList); if(SUCCEEDED(hr)) UXTHEME_broadcast_msg (hwnd, WM_THEMECHANGED); return hr; }
BOOL WINAPI ThemeHooksInstall() { PVOID lpFunc; OSVERSIONINFO osvi; BOOL ret; lpFunc = GetProcAddress(GetModuleHandle("user32.dll"), "RegisterUserApiHook"); ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) { PREGISTER_UAH_WINXP lpfuncxp = (PREGISTER_UAH_WINXP)lpFunc; ret = lpfuncxp(hDllInst, ThemeInitApiHook); } else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) { PREGISTER_UUAH_WIN2003 lpfunc2003 = (PREGISTER_UUAH_WIN2003)lpFunc; USERAPIHOOKINFO uah; uah.m_size = sizeof(uah); uah.m_dllname1 = L"uxtheme.dll"; uah.m_funname1 = L"ThemeInitApiHook"; uah.m_dllname2 = NULL; uah.m_funname2 = NULL; ret = lpfunc2003(&uah); } else { UNIMPLEMENTED; ret = FALSE; } UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED); return ret; }
/*********************************************************************** * EnableTheming (UXTHEME.@) * * NOTES * This is a global and persistent change */ HRESULT WINAPI EnableTheming(BOOL fEnable) { HKEY hKey; WCHAR szEnabled[] = {'0','\0'}; TRACE("(%d)\n", fEnable); if (fEnable != (ActiveThemeFile != NULL)) { if(fEnable) UXTHEME_BackupSystemMetrics(); else UXTHEME_RestoreSystemMetrics(); UXTHEME_SaveSystemMetrics (); if (fEnable) szEnabled[0] = '1'; if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) { RegSetValueExW(hKey, szThemeActive, 0, REG_SZ, (LPBYTE)szEnabled, sizeof(WCHAR)); RegCloseKey(hKey); } UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED); } return S_OK; }