diff options
| author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
| commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
| tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/General/gen_ml/mldwm.cpp | |
| parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
| parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
| download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz | |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Plugins/General/gen_ml/mldwm.cpp')
| -rw-r--r-- | Src/Plugins/General/gen_ml/mldwm.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Src/Plugins/General/gen_ml/mldwm.cpp b/Src/Plugins/General/gen_ml/mldwm.cpp new file mode 100644 index 00000000..14cdd65f --- /dev/null +++ b/Src/Plugins/General/gen_ml/mldwm.cpp @@ -0,0 +1,46 @@ +#include "./mldwm.h" + +typedef HRESULT (WINAPI *DWMSETWINDOWATTRIBUTE)(HWND /*hwnd*/, DWORD /*dwAttribute*/, LPCVOID /*pvAttribute*/, DWORD /*cbAttribute*/); +typedef HRESULT (WINAPI *DWMISCOMPOSITIONENABLED)(BOOL* /*pfEnabled*/); + +static HMODULE hDwmModule = NULL; +static HRESULT loadResult = E_MLDWM_NOTLOADED; + +static DWMSETWINDOWATTRIBUTE fnSetWindowAttribute = NULL; +static DWMISCOMPOSITIONENABLED fnIsCompositionEnabled = NULL; + +HRESULT MlDwm_IsLoaded() +{ + return loadResult; +} + +HRESULT MlDwm_LoadLibrary(void) +{ + if (E_MLDWM_NOTLOADED == loadResult) + { + hDwmModule = LoadLibraryW(L"dwmapi.dll"); + if (!hDwmModule) loadResult = E_MLDWM_LOADFAILED; + else + { + fnSetWindowAttribute = (DWMSETWINDOWATTRIBUTE)GetProcAddress(hDwmModule, "DwmSetWindowAttribute"); + fnIsCompositionEnabled = (DWMISCOMPOSITIONENABLED)GetProcAddress(hDwmModule, "DwmIsCompositionEnabled"); + loadResult = S_OK; + } + } + return loadResult; +} + + +HRESULT MlDwm_SetWindowAttribute(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute) +{ + if (!hDwmModule) return loadResult; + if (!fnSetWindowAttribute) return E_MLDWM_BADFUNCTION; + return fnSetWindowAttribute(hwnd, dwAttribute, pvAttribute, cbAttribute); +} + +HRESULT MlDwm_IsCompositionEnabled(BOOL *pfEnabled) +{ + if (!hDwmModule) return loadResult; + if (!fnIsCompositionEnabled) return E_MLDWM_BADFUNCTION; + return fnIsCompositionEnabled(pfEnabled); +} |
