123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #include "main.h"
- #include "./wintheme.h"
- typedef HRESULT(WINAPI *UXTHEME_SETWINDOWTHEME)(HWND /*hwnd*/, LPCWSTR /*pszSubAppName*/, LPCWSTR /*pszSubIdList*/);
- typedef BOOL (WINAPI *UXTHEME_ISAPPTHEMED)(void);
- typedef HRESULT (WINAPI *DWM_SETWINDOWATTRIBUTE)(HWND /*hwnd*/, DWORD /*dwAttribute*/, LPCVOID /*pvAttribute*/, DWORD /*cbAttribute*/);
- typedef HRESULT (WINAPI *DWM_ISCOMPOSITIONENABLED)(BOOL* /*pfEnabled*/);
- static DWM_SETWINDOWATTRIBUTE fnSetWindowAttribute = NULL;
- static DWM_ISCOMPOSITIONENABLED fnIsCompositionEnabled = NULL;
- static UXTHEME_SETWINDOWTHEME fnSetWindowTheme = NULL;
- static UXTHEME_ISAPPTHEMED fnIsAppThemed = NULL;
- static HMODULE hDwmModule = NULL;
- static HMODULE hUxThemeModule = NULL;
- static HRESULT loadDwmResult = E_LIBRARY_NOTLOADED;
- static HRESULT loadUxThemeResult = E_LIBRARY_NOTLOADED;
- HRESULT UxTheme_LoadLibrary(void)
- {
- if (E_LIBRARY_NOTLOADED == loadUxThemeResult)
- {
- hUxThemeModule = LoadLibraryW(L"uxtheme.dll");
- if (!hUxThemeModule) loadUxThemeResult = E_LIBRARY_LOADFAILED;
- else
- {
- fnSetWindowTheme = (UXTHEME_SETWINDOWTHEME)GetProcAddress(hUxThemeModule, "SetWindowTheme");
- fnIsAppThemed = (UXTHEME_ISAPPTHEMED)GetProcAddress(hUxThemeModule, "IsAppThemed");
- loadUxThemeResult = S_OK;
- }
- }
- return loadUxThemeResult;
- }
- HRESULT Dwm_LoadLibrary(void)
- {
- if (E_LIBRARY_NOTLOADED == loadDwmResult)
- {
- hDwmModule = LoadLibraryW(L"dwmapi.dll");
- if (!hDwmModule) loadDwmResult = E_LIBRARY_LOADFAILED;
- else
- {
- fnSetWindowAttribute = (DWM_SETWINDOWATTRIBUTE)GetProcAddress(hDwmModule, "DwmSetWindowAttribute");
- fnIsCompositionEnabled = (DWM_ISCOMPOSITIONENABLED)GetProcAddress(hDwmModule, "DwmIsCompositionEnabled");
- loadDwmResult = S_OK;
- }
- }
- return loadDwmResult;
- }
- HRESULT UxTheme_GetLoadResult(void)
- {
- return loadUxThemeResult;
- }
- HRESULT Dwm_GetLoadResult()
- {
- return loadDwmResult;
- }
- HRESULT SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList)
- {
- if (!hUxThemeModule) return loadUxThemeResult;
- if (!fnSetWindowTheme) return E_LIBRARY_BADFUNCTION;
- return fnSetWindowTheme(hwnd, pszSubAppName, pszSubIdList);
- }
- BOOL IsAppThemed(void)
- {
- if (!hUxThemeModule) return FALSE;
- if (!fnIsAppThemed) return FALSE;
- return fnIsAppThemed();
- }
- HRESULT DwmSetWindowAttribute(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute)
- {
- if (!hDwmModule) return loadDwmResult;
- if (!fnSetWindowAttribute) return E_LIBRARY_BADFUNCTION;
- return fnSetWindowAttribute(hwnd, dwAttribute, pvAttribute, cbAttribute);
- }
- HRESULT DwmIsCompositionEnabled(BOOL *pfEnabled)
- {
- if (!hDwmModule) return loadDwmResult;
- if (!fnIsCompositionEnabled) return E_LIBRARY_BADFUNCTION;
- return fnIsCompositionEnabled(pfEnabled);
- }
|