DwmSetWindowAttribute function

Sets the value of non-client rendering attributes for a window.


DWMAPI DwmSetWindowAttribute(
  HWND    hwnd,
  DWORD   dwAttribute,
  LPCVOID pvAttribute,
  DWORD   cbAttribute



The handle to the window that will receive the attributes.


A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter points to the value of that attribute.


A pointer to the value of the attribute specified in the dwAttribute parameter. Different DWMWINDOWATTRIBUTE flags require different value types.


The size, in bytes, of the value type pointed to by the pvAttribute parameter.

Return Value

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


Calling this function with the dwAttribute set to DWMWA_NCRENDERING_ENABLED does not set the attribute. DWMWA_NCRENDERING_ENABLED is a "get" attribute and the resulting call is equivalent to a DwmGetWindowAttribute call. To enable or disable non-client rendering, the DWMWA_NCRENDERING_POLICY attribute must set to the desired value.

If Desktop Composition has been disabled, this function returns DWM_E_COMPOSITIONDISABLED.


The following example disables nonclient-area rendering, causing any previous calls to DwmEnableBlurBehindWindow or DwmExtendFrameIntoClientArea to be disabled.

HRESULT DisableNCRendering(HWND hwnd)
   HRESULT hr = S_OK;

   // Disable non-client area rendering on the window.
   hr = DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp));

   if (SUCCEEDED(hr))
      // Do work here. 
   return hr;


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header dwmapi.h
Library Dwmapi.lib
DLL Dwmapi.dll; Uxtheme.dll

See Also

Enable and Control DWM Composition