1 /* 2 * PROJECT: ReactOS Applications 3 * LICENSE: LGPL - See COPYING in the top level directory 4 * FILE: base/applications/msconfig_new/comctl32ex/uxthemesupp.c 5 * PURPOSE: UX Theming helpers. 6 * COPYRIGHT: Copyright 2015 Hermes BELUSCA - MAITO <hermes.belusca@sfr.fr> 7 */ 8 9 #include "precomp.h" 10 #include "uxthemesupp.h" 11 12 static HMODULE hUxTheme = NULL; 13 14 typedef HRESULT (WINAPI* ETDTProc)(HWND, DWORD); 15 static ETDTProc fnEnableThemeDialogTexture = NULL; 16 17 typedef HRESULT (WINAPI* SWTProc)(HWND, LPCWSTR, LPCWSTR); 18 static SWTProc fnSetWindowTheme = NULL; 19 20 21 static BOOL 22 InitUxTheme(VOID) 23 { 24 if (hUxTheme) return TRUE; 25 26 hUxTheme = LoadLibraryW(L"uxtheme.dll"); 27 if (hUxTheme == NULL) return FALSE; 28 29 fnEnableThemeDialogTexture = 30 (ETDTProc)GetProcAddress(hUxTheme, "EnableThemeDialogTexture"); 31 fnSetWindowTheme = 32 (SWTProc)GetProcAddress(hUxTheme, "SetWindowTheme"); 33 34 return TRUE; 35 } 36 37 #if 0 38 static VOID 39 CleanupUxTheme(VOID) 40 { 41 FreeLibrary(hUxTheme); 42 hUxTheme = NULL; 43 } 44 #endif 45 46 47 //////////////////////////////////////////////////////////////////////////////// 48 // Taken from WinSpy++ 1.7 49 // http://www.catch22.net/software/winspy 50 // Copyright (c) 2002 by J Brown 51 // 52 53 HRESULT 54 WINAPI 55 EnableThemeDialogTexture(_In_ HWND hwnd, 56 _In_ DWORD dwFlags) 57 { 58 if (!InitUxTheme()) 59 return HRESULT_FROM_WIN32(GetLastError()); 60 61 if (!fnEnableThemeDialogTexture) 62 return HRESULT_FROM_WIN32(GetLastError()); 63 64 return fnEnableThemeDialogTexture(hwnd, dwFlags); 65 } 66 67 HRESULT 68 WINAPI 69 SetWindowTheme(_In_ HWND hwnd, 70 _In_ LPCWSTR pszSubAppName, 71 _In_ LPCWSTR pszSubIdList) 72 { 73 if (!InitUxTheme()) 74 return HRESULT_FROM_WIN32(GetLastError()); 75 76 if (!fnSetWindowTheme) 77 return HRESULT_FROM_WIN32(GetLastError()); 78 79 return fnSetWindowTheme(hwnd, pszSubAppName, pszSubIdList); 80 } 81