/
DcxDWMModule.cpp
109 lines (93 loc) · 3.79 KB
/
DcxDWMModule.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "defines.h"
#include "DcxDWMModule.h"
PFNDWMISCOMPOSITIONENABLED DcxDWMModule::DwmIsCompositionEnabledUx = NULL;
PFNDWMGETWINDOWATTRIBUTE DcxDWMModule::DwmGetWindowAttributeUx = NULL;
PFNDWMSETWINDOWATTRIBUTE DcxDWMModule::DwmSetWindowAttributeUx = NULL;
PFNDWMEXTENDFRAMEINTOCLIENTAREA DcxDWMModule::DwmExtendFrameIntoClientAreaUx = NULL;
PFNDWMENABLEBLURBEHINDWINDOW DcxDWMModule::DwmEnableBlurBehindWindowUx = NULL;
PFNDWMGETCOLORIZATIONCOLOR DcxDWMModule::DwmGetColorizationColorUx = NULL;
DcxDWMModule::DcxDWMModule(void)
{
m_bAero = false;
}
DcxDWMModule::~DcxDWMModule(void)
{
if (isUseable()) unload();
}
bool DcxDWMModule::load(mIRCLinker &mIRCLink)
{
if (isUseable()) return false;
//DcxModule::load(mIRCLink); // does nothing
DCX_DEBUG(mIRCLink.debug,TEXT("LoadDLL"), TEXT("Loading DWMAPI.DLL..."));
m_hModule = LoadLibrary(TEXT("dwmapi.dll"));
if (m_hModule != NULL) {
DCX_DEBUG(mIRCLink.debug,TEXT("LoadDLL"), TEXT("DWMAPI.DLL Loaded, Vista+ OS Assumed"));
DwmIsCompositionEnabledUx = (PFNDWMISCOMPOSITIONENABLED) GetProcAddress(m_hModule, "DwmIsCompositionEnabled"); // Vista ONLY!
DwmGetWindowAttributeUx = (PFNDWMGETWINDOWATTRIBUTE) GetProcAddress(m_hModule, "DwmGetWindowAttribute"); // Vista ONLY!
DwmSetWindowAttributeUx = (PFNDWMSETWINDOWATTRIBUTE) GetProcAddress(m_hModule, "DwmSetWindowAttribute"); // Vista ONLY!
DwmExtendFrameIntoClientAreaUx = (PFNDWMEXTENDFRAMEINTOCLIENTAREA) GetProcAddress(m_hModule, "DwmExtendFrameIntoClientArea"); // Vista ONLY!
DwmEnableBlurBehindWindowUx = (PFNDWMENABLEBLURBEHINDWINDOW) GetProcAddress(m_hModule, "DwmEnableBlurBehindWindow"); // Vista ONLY!
DwmGetColorizationColorUx = (PFNDWMGETCOLORIZATIONCOLOR) GetProcAddress(m_hModule, "DwmGetColorizationColor"); // Vista ONLY!
#if DCX_DEBUG_OUTPUT
if (DwmIsCompositionEnabledUx != NULL)
mIRCLink.debug(TEXT("LoadDLL"), TEXT("Found Vista DWM Functions"));
#endif
refreshComposite();
}
return isUseable();
}
bool DcxDWMModule::unload(void)
{
if (m_hModule != NULL) {
FreeLibrary(m_hModule);
m_hModule = NULL;
return true;
}
return false;
}
bool DcxDWMModule::refreshComposite() {
BOOL bAero = FALSE;
dcxDwmIsCompositionEnabled(&bAero);
if (bAero)
m_bAero = true;
else
m_bAero = false;
return m_bAero;
}
HRESULT DcxDWMModule::dcxDwmSetWindowAttribute(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute)
{
if (DwmSetWindowAttributeUx != NULL)
return DwmSetWindowAttributeUx(hwnd, dwAttribute, pvAttribute, cbAttribute);
return DWM_E_COMPOSITIONDISABLED;
}
HRESULT DcxDWMModule::dcxDwmGetWindowAttribute(HWND hwnd, DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute)
{
if (DwmGetWindowAttributeUx != NULL)
return DwmGetWindowAttributeUx(hwnd, dwAttribute, pvAttribute, cbAttribute);
return DWM_E_COMPOSITIONDISABLED;
}
HRESULT DcxDWMModule::dcxDwmIsCompositionEnabled(BOOL *pfEnabled)
{
if (DwmIsCompositionEnabledUx != NULL)
return DwmIsCompositionEnabledUx(pfEnabled);
*pfEnabled = FALSE;
return DWM_E_COMPOSITIONDISABLED;
}
HRESULT DcxDWMModule::dcxDwmExtendFrameIntoClientArea(HWND hwnd, const MARGINS *pMarInset)
{
if (DwmExtendFrameIntoClientAreaUx != NULL)
return DwmExtendFrameIntoClientAreaUx(hwnd, pMarInset);
return DWM_E_COMPOSITIONDISABLED;
}
HRESULT DcxDWMModule::dcxDwmEnableBlurBehindWindow(HWND hwnd, __in const DWM_BLURBEHIND *pBlurBehind)
{
if (DwmEnableBlurBehindWindowUx != NULL)
return DwmEnableBlurBehindWindowUx(hwnd, pBlurBehind);
return DWM_E_COMPOSITIONDISABLED;
}
HRESULT DcxDWMModule::dcxDwmGetColorizationColor( __out DWORD *pcrColorization, __out BOOL *pfOpaqueBlend)
{
if (DwmGetColorizationColorUx != NULL)
return DwmGetColorizationColorUx(pcrColorization, pfOpaqueBlend);
return DWM_E_COMPOSITIONDISABLED;
}