DwmEnableComposition function
Applies to: desktop apps only
Enables or disables Desktop Window Manager (DWM) composition.
Note This function is deprecated as of Windows 8 Consumer Preview. DWM can no longer be programmatically disabled.
Syntax
HRESULT WINAPI DwmEnableComposition( UINT uCompositionAction );
Parameters
- uCompositionAction
-
DWM_EC_ENABLECOMPOSITION to enable DWM composition; DWM_EC_DISABLECOMPOSITION to disable composition.
Note As of Windows 8, calling this function with DWM_EC_DISABLECOMPOSITION has no effect. However, the function will still return a success code.
Return value
If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
Disabling DWM composition disables it for the entire desktop. DWM composition will be automatically enabled when all processes that have disabled composition have called DwmEnableComposition to enable it or have been terminated. The WM_DWMCOMPOSITIONCHANGED notification is sent whenever DWM composition is enabled or disabled.
Examples
The following code example disables DWM composition.
...
HRESULT hr = S_OK;
// Disable DWM Composition
hr = DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);
if (SUCCEEDED(hr))
{
// ...
}
...
Requirements
|
Minimum supported client | Windows Vista |
|---|---|
|
Minimum supported server | Windows Server 2008 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 2/14/2012
Since XP doesn't have dwmapi.dll you can't link against it, so to have it in your program that also runs on XP, dynamic link against it, like:
typedef HRESULT (WINAPI * DwmEnableCompositionFunction)(__in UINT uCompositionAction);HRESULT turnOffAero() {
HRESULT aResult = S_OK;
HMODULE dwmapiDllHandle = LoadLibrary(L"dwmapi.dll");
if (NULL != dwmapiDllHandle ) // not on Vista/Windows7 so no aero so no need to account for aero.
{
DwmEnableCompositionFunction DwmEnableComposition;
DwmEnableComposition = (DwmEnableCompositionFunction) ::GetProcAddress(dwmapiDllHandle, "DwmEnableComposition");
if( NULL != DwmEnableComposition )
{
aResult = DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);
}
FreeLibrary(dwmapiDllHandle);
}
return aResult;
}
- 4/23/2012
- rogerdpack2
- 4/26/2012
- rogerdpack2
- 10/26/2011
- Krystian Bigaj
- 10/26/2011
- Krystian Bigaj
- 10/5/2010
- adeyblue
//Alexander Klimoff (http://developer.alexanderklimov)// See also MSDN Magazine April 2007
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern int DwmEnableComposition(bool fEnable);// turn off Aero Glass
DwmEnableComposition(false);