Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Reference
Functions
 DwmSetWindowAttribute Function
DwmSetWindowAttribute Function

Sets the value of the specified DWMWINDOWATTRIBUTE to apply to the window.

Syntax

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

Parameters

hwnd
The window handle to apply the given attribute.
dwAttribute
The DWMWINDOWATTRIBUTE to apply to the window.
pvAttribute
[in] The pointer to the DWMWINDOWATTRIBUTE value to apply. The type is dependent on the value of the dwAttribute parameter.
cbAttribute
The size of the DWMWINDOWATTRIBUTE value being retrieved. The size is dependent on the type of the pvAttribute parameter.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

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

Example

The following example disables non-client 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 window
   hr = DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp));
   if (SUCCEEDED(hr))
   {
      //do more stuff
   }
   return hr;
}

Function Information

Minimum DLL Versiondwmapi.dll
Headerdwmapi.h
Import librarydwmapi.lib
Minimum operating systems Windows Vista

See Also

Enable and Control DWM Composition
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker