DwmEnableBlurBehindWindow function

Enables the blur effect on a specified window.


HRESULT WINAPI DwmEnableBlurBehindWindow(
             HWND           hWnd,
  _In_ const DWM_BLURBEHIND *pBlurBehind



The handle to the window on which the blur behind data is applied.

pBlurBehind [in]

A pointer to a DWM_BLURBEHIND structure that provides blur behind data.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


Enabling blur by setting the fEnable member of the DWM_BLURBEHIND structure to TRUE. This results in subsequent compositions of the window blurring the content behind it. This function should be called immediately before a BeginPaint call to ensure prompt application of the effect.

The alpha values in the window are honored and the rendering atop the blur will use these alpha values. It is the application's responsibility to ensure that the alpha values of all pixels in the window are correct. Some Windows Graphics Device Interface (GDI) operations do not preserve alpha values, so care must be taken when presenting child windows because the alpha values they contribute are unpredictable.

The region specified within the DWM_BLURBEHIND structure is owned by the caller. It is the caller's responsibility to free the region, and they can do so as soon as the function call is completed.

This function can only be called on top-level windows. An error occurs when this function is called on other window types.

This function must be called whenver Desktop Window Manager (DWM) composition is toggled. Handle the WM_DWMCOMPOSITIONCHANGED message for composition change notification.


The following example demonstrates how to apply the blur behind the entire window.

HRESULT EnableBlurBehind(HWND hwnd)
   HRESULT hr = S_OK;

   // Create and populate the Blur Behind structure
   DWM_BLURBEHIND bb = {0};

   // Enable Blur Behind and apply to the entire client area
   bb.dwFlags = DWM_BB_ENABLE;
   bb.fEnable = true;
   bb.hRgnBlur = NULL;

   // Apply Blur Behind
   hr = DwmEnableBlurBehindWindow(hwnd, &bb);
   if (SUCCEEDED(hr))
      // ...
   return hr;


Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]







See also

DWM Blur Behind Overview