如何在Windows上实现桌面叠加模糊?

问题描述 投票:4回答:1

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

AMD Radeon Installer

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

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

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

c# windows winforms effects dwm
1个回答
3
投票

经过几个月的搜索,我终于找到了the answer。要在Windows 10上实现玻璃效果,必须在SetWindowCompositionAttribute中使用未记录的user32.dll函数。

Windows 10 Aero Glass Demonstration

BOOL WINAPI SetWindowCompositionAttribute(HWND hwnd, WINCOMPATTRDATA* pAttrData)

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

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

© www.soinside.com 2019 - 2024. All rights reserved.