Download presentation
Presentation is loading. Please wait.
1
Desktop Window Manager
Mindaugas Butkus IV kursas, PS2 grupė
2
Features Glass window frames; 3-D window transition animation;
Windows Flip and Windows Flip3D; Live taskbar thumbnails; High resolution support.
3
How to use it #include <Dwmapi.h> Link with Dwmapi.lib
DLL: Dwmapi.dll
4
Retrieving the Colorization Information
HRESULT WINAPI DwmGetColorizationColor( _Out_ DWORD *pcrColorization, _Out_ BOOL *pfOpaqueBlend ); pcrColorization [out] A pointer to a value that, when this function returns successfully, receives the current color used for glass composition. The color format of the value is 0xAARRGGBB. pfOpaqueBlend [out] A pointer to a value that, when this functions returns successfully, indicates whether the color is an opaque blend. TRUE if the color is an opaque blend; otherwise, FALSE.
5
Retrieving the Colorization Information
... case WM_DWMCOLORIZATIONCOLORCHANGED: { g_currColor = (DWORD)wParam; g_opacityblend = (BOOL)lParam; } break; ...
6
Controlling Non-Client Region Rendering
HRESULT WINAPI DwmGetWindowAttribute( HWND hwnd, DWORD dwAttribute, _Out_ PVOID pvAttribute, DWORD cbAtribute); hwnd – the handle to the window from which the attribute data is retrieved. dwAttribute – the attribute to retrieve, specified as a DWMWINDOWATTRIBUTE value. pvAttribute[out] – a pointer to a value that, when this function returns successfully, received the current value of the attribute. The type depends on the dwAttribute parameter. cbAttribute – the size of the DWMWINDOWATTRIBUTE value being retrieved. Depends on pvAttribute.
7
DWMWINDOWATTRIBUTE enum
typedef enum _DWMWINDOWATTRIBUTE { DWMWA_NCRENDERING_ENABLED = 1, DWMWA_NCRENDERING_POLICY, DWMWA_TRANSITIONS_FORCEDISABLED, DWMWA_ALLOW_NCPAINT, DWMWA_CAPTION_BUTTON_BOUNDS, DWMWA_NONCLIENT_RTL_LAYOUT, DWMWA_FORCE_ICONIC_REPRESENTATION, DWMWA_FLIP3D_POLICY, DWMWA_EXTENDED_FRAME_BOUNDS, DWMWA_HAS_ICONIC_BITMAP, DWMWA_DISALLOW_PEEK, DWMWA_EXCLUDED_FROM_PEEK, DWMWA_CLOAK, DWMWA_CLOAKED, DWMWA_FREEZE_REPRESENTATION, DWMWA_LAST } DWMWINDOWATTRIBUTE;
8
DwmGetWindowAttribute example
HRESULT IsNCRenderingEnabled(HWND hwnd, BOOL enabled) { HRESULT hr = S_OK; hr = DwmGetWindowAttribute(hwnd, DWMWA_NCRENDERING_ENABLED, &enabled, sizeof(BOOL)); if (SUCCEEDED(hr)) { // Use the retrieved information } return hr; }
9
Controlling Non-Client Region Rendering
HRESULT WINAPI DwmSetWindowAttribute( HWND hwnd, DWORD dwAttribute, _In_ LPCVOID pvAttribute, DWORD cbAttribute); hwnd – the handle to the window that will receive the attribute. dwAttribute – a single DWMWINDOWATTRIBUTE flag to apply to the window. pvAttribute[in] – a pointer to the value of the attribute specified in the dwAttribute parameter. cbAttribute – the size, in bytes, of the value type pointed to by the pvAttribute parameter.
10
DwmSetWindowAttribute example
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; }
11
DwmSetWindowAttribute example
ENABLED non-client area rendering Disabled non-client area rendering
12
Adding Blur to a Specific Region of the Client Area
HRESULT WINAPI DwmEnableBlurBehindWindow( HWND hWnd, _In_ const DWM_BLURBEHIND *pBlurBehind); hWnd – The handle to the window on which the blur behind data is applied. pBlurBehind – A pointer to a DWM_BLURBEHIND structure that provides blur behind data.
13
DWM_BLURBEHIND struct
typedef struct _DWM_BLURBEHIND { DWORD dwFlags; BOOL fEnable; HRGN hRgnBlur; BOOL fTransitionOnMaximized; } DWM_BLURBEHIND, *PDWM_BLURBEHIND; dwFlags – A bitwise combination of DWM Blur Behind constant values (DWM_BB_ENABLE, DWM_BB_BLURREGION, DWM_BB_TRANSITIONONMAXIMIZED) that indicates which of the members of this structure have been set. fEnable – TRUE to register the window handle to DWM blur behind; FALSE to unregister the window handle from DWM blur behind. hRgnBlur – The region within the client area where the blur behind will be applied. A NULL value will apply the blur behind the entire client area. fTransitionOnMaximized – TRUE if the window's colorization should transition to match the maximized windows; otherwise, FALSE.
14
DwmEnableBlurBehindWindow example
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; }
15
DwmEnableBlurBehindWindow example
16
Extending the Window Frame into the Client Area
HRESULT WINAPI DwmExtendFrameIntoClientArea( HWND hWnd, _In_ const MARGINS *pMarInset); hWnd – The handle to the window in which the frame will be extended into the client area. pMarInset – A pointer to a MARGINS structure that describes the margins to use when extending the frame into the client area. typedef struct _MARGINS { int cxLeftWidth; int cxRightWidth; int cyTopHeight; int cyBottomHeight; } MARGINS, *PMARGINS;
17
ExtendIntoClientBottom example
HRESULT ExtendIntoClientBottom(HWND hwnd) { HRESULT hr = S_OK; // Set the margins, extending the bottom margin MARGINS margins = {0,0,0,25}; // Extend the frame on the bottom of the client area hr = DwmExtendFrameIntoClientArea(hwnd,&margins); if (SUCCEEDED(hr)) { // } return hr; }
18
ExtendIntoClientBottom example
19
“Sheet of glass” effect
HRESULT ExtendIntoClientAll(HWND hwnd) { HRESULT hr = S_OK; // Negative margins have special meaning to DwmExtendFrameIntoClientArea // Negative margins create the "sheet of glass" effect, where the client // area is rendered as a solid surface without a window border MARGINS margins = {-1}; // Extend the frame across the whole window hr = DwmExtendFrameIntoClientArea(hwnd,&margins); if (SUCCEEDED(hr)) { // } return hr; }
20
“Sheet of glass” effect
21
Live taskbar thumbnails
22
Live taskbar thumbnails
HRESULT WINAPI DwmRegisterThumbnail( HWND hwndDestination, HWND hwndSource, _Out_ PHTHUMBNAIL phThumbnailId); hwndDestination – The handle to the window that will use the DWM thumbnail. Setting the destination window handle to anything other than a top-level window type will result in a return value of E_INVALIDARG. hwndSource – The handle to the window to use as the thumbnail source. Setting the source window handle to anything other than a top-level window type will result in a return value of E_INVALIDARG. phThumbnailId – A pointer to a handle that, when this function returns successfully, represents the registration of the DWM thumbnail.
23
Live taskbar thumbnails
HRESULT WINAPI DwmUpdateThumbnailProperties( HTHUMBNAIL hThumbnailId, _In_ const DWM_THUMBNAIL_PROPERTIES *ptnProperties); hThumbnailId – The handle to the DWM thumbnail to be updated. Null or invalid thumbnails, as well as thumbnails owned by other processes will result in a return value of E_INVALIDARG. ptnProperties – A pointer to a DWM_THUMBNAIL_PROPERTIES structure that contains the new thumbnail properties.
24
DWM_THUMBNAIL_PROPERTIES struct
typedef struct _DWM_THUMBNAIL_PROPERTIES { DWORD dwFlags; RECT rcDestination; RECT rcSource; BYTE opacity; BOOL fVisible; BOOL fSourceClientAreaOnly; } DWM_THUMBNAIL_PROPERTIES, *PDWM_THUMBNAIL_PROPERTIES; dwFlags – A bitwise combination of DWM thumbnail constant values (DWM_TNP_RECTDESTINATION, DWM_TNP_RECTSOURCE, DWM_TNP_OPACITY, DWM_TNP_VISIBLE, DWM_TNP_SOURCECLIENTAREAONLY) that indicates which members of this structure are set.
25
DWM_THUMBNAIL_PROPERTIES struct
rcDestination – The area in the destination window where the thumbnail will be rendered. rcSource – The region of the source window to use as the thumbnail. By default, the entire window is used as the thumbnail. opacity – The opacity with which to render the thumbnail. 0 is fully transparent while 255 is fully opaque. The default value is 255. fVisible – TRUE to make the thumbnail visible; otherwise, FALSE. The default is FALSE. fSourceClientAreaOnly – TRUE to use only the thumbnail source's client area; otherwise, FALSE. The default is FALSE.
26
Live taskbar thumbnails
HRESULT WINAPI DwmQueryThumbnailSourceSize( HTHUMBNAIL hThumbnail, _Out_ PSIZE pSize); hThumbnail – A handle to the thumbnail to retrieve the source window size from. pSize – A pointer to a SIZE structure that, when this function returns successfully, receives the size of the source thumbnail.
27
Live taskbar thumbnails
HRESULT WINAPI DwmUnregisterThumbnail( HTHUMBNAIL hThumbnailId); hThumbnailId – The handle to the thumbnail relationship to be removed. Null or non-existent handles will result in a return value of E_INVALIDARG.
28
Live taskbar thumbnails example
HRESULT hr = S_OK; HTHUMBNAIL thumbnail = NULL; // Register the thumbnail hr = DwmRegisterThumbnail(hwnd, FindWindow(_T("Progman"), NULL), &thumbnail); if (SUCCEEDED(hr)) { // Specify the destination rectangle size RECT dest = {0,50,100,150}; // Set the thumbnail properties for use DWM_THUMBNAIL_PROPERTIES dskThumbProps; dskThumbProps.dwFlags = DWM_TNP_SOURCECLIENTAREAONLY | DWM_TNP_VISIBLE | DWM_TNP_OPACITY | DWM_TNP_RECTDESTINATION; dskThumbProps.fSourceClientAreaOnly = FALSE; dskThumbProps.fVisible = TRUE; dskThumbProps.opacity = (255 * 70)/100; dskThumbProps.rcDestination = dest; // Display the thumbnail hr = DwmUpdateThumbnailProperties(thumbnail,&dskThumbProps); if (SUCCEEDED(hr)) { // } } return hr;
29
DWM usage examples
30
DWM usage examples
31
Sources
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.