Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I achieve desktop overlay blur on Windows?

When I was installing AMD graphics drivers on Windows 10, I noticed a blurred background look, which is a style I want to achieve in my application.

AMD Radeon Installer

I have tried using UpdateLayeredWindow, but it does not apply a blur effect. I have tried using DwmExtendFrameIntoClientArea and DwmEnableBlurBehindWindow but I am unsure how to customize window coloring and image overlays.

There is a DwmGetColorizationColor function, but there is no matching DwmSetColorizationColor function. There are ways to set system-wide coloring, but I would like colorization to affect solely my application window. Also, Aero Glass™ was removed from Windows 8 and 10.

How do I include these effects in my application using WinForms in a way that works on Windows 8/10? If WPF can render these effects, how does it do it and how do I achieve a similar effect on WinForms?

like image 427
MathuSum Mut Avatar asked Aug 04 '17 06:08

MathuSum Mut


People also ask

How do I get rid of the blur on Windows 10?

Turn the setting for fixing blurry apps on or off manuallyIn the search box on the taskbar, type advanced scaling settings and select Fix apps that are blurry. In Fix scaling for apps, turn on or off Let Windows try to fix apps so they're not blurry.


1 Answers

After months of searching, I have finally found the answer. To achieve the glass effect on Windows 10, one must use the undocumented SetWindowCompositionAttribute function in user32.dll.

Windows 10 Aero Glass Demonstration

BOOL WINAPI SetWindowCompositionAttribute(HWND hwnd, WINCOMPATTRDATA* pAttrData)

where the layout of the WINCOMPATTRDATA structure is:

struct WINCOMPATTRDATA {
    DWORD attribute; // the attribute to query, see below
    PVOID pData; //buffer to store the result
    ULONG dataSize; //size of the pData buffer
};

and attribute can have values from the DWMWINDOWATTRIBUTE enum.

like image 190
MathuSum Mut Avatar answered Sep 24 '22 17:09

MathuSum Mut