如何在 Windows 上实现桌面覆盖模糊?

Mat*_*Mut 5 c# windows effects dwm winforms

当我在 Windows 10 上安装 AMD 图形驱动程序时,我注意到背景外观模糊,这是我希望在我的应用程序中实现的风格。

AMD Radeon 安装程序

我曾尝试使用UpdateLayeredWindow,但它没有应用模糊效果。我曾尝试使用DwmExtendFrameIntoClientAreaDwmEnableBlurBehindWindow,但我不确定如何自定义窗口着色和图像叠加。

有一个DwmGetColorizationColor函数,但没有匹配的 DwmSetColorizationColor 函数。有多种方法可以设置系统范围的着色,但我希望着色仅影响我的应用程序窗口。此外,Aero Glass™ 已从 Windows 8 和 10 中删除。

如何以适用于 Windows 8/10 的方式使用 WinForms 在我的应用程序中包含这些效果?如果 WPF 可以呈现这些效果,它是如何做到的,我如何在 WinForms 上实现类似的效果?

Mat*_*Mut 5

经过几个月的寻找,我终于找到了答案要在 Windows 10 上实现玻璃效果,必须使用user32.dll.

Windows 10 Aero 玻璃演示

BOOL WINAPI SetWindowCompositionAttribute(HWND hwnd, WINCOMPATTRDATA* pAttrData)
Run Code Online (Sandbox Code Playgroud)

其中结构的布局WINCOMPATTRDATA是:

struct WINCOMPATTRDATA {
    DWORD attribute; // the attribute to query, see below
    PVOID pData; //buffer to store the result
    ULONG dataSize; //size of the pData buffer
};
Run Code Online (Sandbox Code Playgroud)

并且attribute可以具有来自DWMWINDOWATTRIBUTE枚举的值。