win10的透明毛玻璃,winform和wpf方法,win7、8不能用,只是win10
public partial class Form1 : Form
{
[DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data); [StructLayout(LayoutKind.Sequential)]
internal struct WindowCompositionAttributeData
{
public WindowCompositionAttribute Attribute;
public IntPtr Data;
public int SizeOfData;
} internal enum WindowCompositionAttribute
{
WCA_ACCENT_POLICY = 19
} internal enum AccentState
{
ACCENT_DISABLED = 0,
ACCENT_ENABLE_GRADIENT = 1,
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
ACCENT_ENABLE_BLURBEHIND = 3,
ACCENT_INVALID_STATE = 4
} [StructLayout(LayoutKind.Sequential)]
internal struct AccentPolicy
{
public AccentState AccentState;
public int AccentFlags;
public int GradientColor;
public int AnimationId;
} internal void EnableBlur()
{
var accent = new AccentPolicy();
var accentStructSize = Marshal.SizeOf(accent);
accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND; var accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false); var data = new WindowCompositionAttributeData();
data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
data.SizeOfData = accentStructSize;
data.Data = accentPtr; SetWindowCompositionAttribute(this.Handle, ref data); Marshal.FreeHGlobal(accentPtr);
}
...................
...................
private void Form1_Load(object sender, EventArgs e)
{
EnableBlur();
} 窗体背景设置比如Red,然后TransparencyKey=Red,就有行了。 如果使用WPF,修改:
internal void EnableBlur()
{
var windowHelper = new WindowInteropHelper(this);
......
......
SetWindowCompositionAttribute(windowHelper.Handle, ref data);
......
}

windows 10 透明毛玻璃,winform和wpf方法的更多相关文章

  1. 支持 Windows 10 最新 PerMonitorV2 特性的 WPF 多屏高 DPI 应用开发

    Windows 10 自 1703 开始引入第二代的多屏 DPI 机制(PerMonitor V2),而 WPF 框架可以支持此第二代的多屏 DPI 机制. 本文将介绍 WPF 框架利用第二代多屏 D ...

  2. 【技巧】Windows 10 1809无法接收1903解决方法

    这都7月份了,Windows10 1903都升级的有一个月了,然而我的1809的系统一直找不到1903的更新. 虽说1903会有bug,但还是想体验一把.周围同事都更新了,心里还是痒痒的. 于是每天都 ...

  3. Win10系统下如何禁止同步主机session?windows 10禁止同步主机session的方法

    近来,有些刚刚升级Win10正式版的用户反映自己的电脑开机时有个同步主机session启动项占用了将近半分钟,而选择用360禁止后,下次会出现同步主机session3,再禁止下次又会出现同步主机ses ...

  4. Windows 10 版本 1507 中的新 AppLocker 功能

    要查看 Windows 10 版本信息,使用[运行]> dxdiag  回车 下表包含 Windows 10 的初始版本(版本 1507)中包括的一些新的和更新的功能以及对版本 1511 的 W ...

  5. Windows 10创意者更新ISO发布!官方下载

    http://news.mydrivers.com/1/526/526719.htm 去年7月份,微软面向Windows 10推出了“周年更新”,让系统变得更加稳定好用.今天,Windows 10迎来 ...

  6. 如何在Windows 10安装和使用Linux的Bash shell

    转载自:百度经验 Windwos 10 的周年更新为开发人员提供一个大的新功能:一个完整的,基于Ubuntu的Bash shell中,可以直接在Windows上运行Linux软件. 这使得“Linux ...

  7. Windows 10 应用创建模糊背景窗口的三种方法

    原文 Windows 10 应用创建模糊背景窗口的三种方法 现代的操作系统中创建一张图片的高斯模糊效果非常容易,不过如果要在窗口中获得模糊支持就需要操作系统的原生支持了.iOS/Mac 和 Windo ...

  8. winform,wpf全屏 还显示任务栏的解决方法

    原文:winform,wpf全屏 还显示任务栏的解决方法 以wpf为例: 全屏代码: this.Topmost = true; this.WindowStyle = System.Windows.Wi ...

  9. 在 WPF 程序中应用 Windows 10 真?亚克力效果

    原文:在 WPF 程序中应用 Windows 10 真?亚克力效果 从 Windows 10 (1803) 开始,Win32 应用也可以有 API 来实现原生的亚克力效果了.不过相比于 UWP 来说, ...

随机推荐

  1. final link failed: Nonrepresentable section on output

    编译live555的时候遇到了这个问题,前面的编译没有问题,是在链接的时候出现的,在网上搜索说是缺少 libstdc++ 库.于是,安装之 #sudo apt-get install  libstdc ...

  2. Laya for H5 之Bug追踪

    Laya For H5之Bug追踪 H5游戏一旦上线后,如何跟踪用户的崩溃日志呢?现在有很多第三方的工具,比如fundebug,其sdk接入简单,只需寥寥几行代码就可以追踪h5游戏的崩溃日志,bug日 ...

  3. 饿了么测试专场技术沙龙实况回顾&PPT 下载

    PPT下载和视频观看链接 链接:https://pan.baidu.com/s/1dE8uXHZ 密码:6j5z视频直播回顾: http://www.itdks.com/dakashuo/playba ...

  4. [ZZ]新手学 appium-合集第一季度

    原文地址: https://testerhome.com/topics/2599 新手学appium-合集第一季度地址如下: 1.新手学 appium-GUI 端搞起来:http://testerho ...

  5. conda,pip 安装指定版本的指定包

    1.conda 安装指定版本的指定包 cuda search tensorflow-gpu 有如下结果: 然后使用conda install package=version 就能安装指定版本的pack ...

  6. android 显示大图模糊问题

    使用Glide 版本为4.8.0 /* */ Glide.with(context).asBitmap().load(url).into(new SimpleTarget<Bitmap>( ...

  7. CPU的概念

    1.CPU的运算都是以纳秒为单位的,内存相比要慢百倍,硬盘要慢百万倍. 2.CPU的主要工作就是运行指令,指令全在内存里,第一条指令地址为0xFFFFFF0处(BIOS发出的跳转指令). 3.CPU工 ...

  8. springboot项目如何打包成war包

    一.修改打包形式 在pom.xml里设置 <packaging>war</packaging> 二.移除嵌入式tomcat插件 在pom.xml里找到spring-boot-s ...

  9. C#添加VisionPro控件问题

    安装完VisionPro8.2版本以后,用VS2013调用时,没有默认在工具箱内,那么就需要手动添加了,选择菜单栏---->工具----->选择工具箱项,如下图所示:           ...

  10. LeetCode 789. Escape The Ghosts

    题目链接:https://leetcode.com/problems/escape-the-ghosts/description/ You are playing a simplified Pacma ...