Export (0) Print
Expand All

DwmSetWindowAttribute function

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

Syntax


HRESULT WINAPI DwmSetWindowAttribute(
  HWND hwnd,
  DWORD dwAttribute,
  _In_  LPCVOID pvAttribute,
  DWORD cbAttribute
);

Parameters

hwnd

The handle to the window that will receive the attributes.

dwAttribute

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.

pvAttribute [in]

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

cbAttribute

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.

Remarks

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.

Examples

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;
   DWMNCRENDERINGPOLICY ncrp = DWMNCRP_DISABLED;

   // 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;
}

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Dwmapi.h

Library

Dwmapi.lib

DLL

Dwmapi.dll

See also

Enable and Control DWM Composition

 

 

Community Additions

ADD
Show:
© 2014 Microsoft