C# WinForm实现Windows 7 Aero磨砂玻璃效果
在Vista系统之后,微软为窗体程序提供了Aero磨砂的效果,如下图。那么用C#如
何来实现这种磨砂效果呢?

代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;//引用DLL申明 namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
//DLL申明
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int Left;
public int Right;
public int Top;
public int Bottom;
} //DLL申明
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS
margins); //DLL申明
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern bool DwmIsCompositionEnabled(); //直接添加代码
protected override void OnLoad(EventArgs e)
{
if (DwmIsCompositionEnabled())
{
MARGINS margins = new MARGINS();
margins.Right = margins.Left = margins.Top = margins.Bottom =
this.Width + this.Height;
DwmExtendFrameIntoClientArea(this.Handle, ref margins);
}
base.OnLoad(e);
} //直接添加代码
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
if (DwmIsCompositionEnabled())
{
e.Graphics.Clear(Color.Black);
}
} public Form1()
{
InitializeComponent();
}
}
}
这中效果的实现主要是调用了系统的dwmapi.dll。
dwmapi.dll是Microsoft Desktop Window Manager API(桌面窗口管理器DWM 的公用界面)的动态链接库,正常文件,主要用作桌面效果的api。
DWM 是一种新界面,在除 Windows Vista Home Basic 之外的所有 Windows Vista 版本中均提供 DWM 界面。所以这种效果只能在Vista之后的系统中使用。
C# WinForm实现Windows 7 Aero磨砂玻璃效果的更多相关文章
- [转]WinForm实现win7 Aero磨砂效果介绍
WinForm实现win7 Aero磨砂效果如下: WinForm实现win7 Aero磨砂效果代码如下: using System; using System.Collections.Generic ...
- Windows 7 扩展玻璃效果(Aero Glass)
转自:http://www.cnblogs.com/gnielee/archive/2010/10/04/windows7-extend-aero-glass.html Windows 7 操作系统默 ...
- 【转】MFC 迅雷七窗体特效,使用DWM实现Aero Glass效果
从Windows Vista开始,Aero Glass效果被应用在了Home Premium以上的系统中(Home Basic不具有该效果).这种效果是由DWM(Desktop Window Mana ...
- 窗口玻璃特效,半透明窗口,使用DWM实现Aero Glass效果
转自:http://blog.csdn.net/ntwilford/article/details/5656633 从Windows Vista开始,Aero Glass效果被应用在了Home Pre ...
- 在 WPF 程序中应用 Windows 10 真?亚克力效果
原文:在 WPF 程序中应用 Windows 10 真?亚克力效果 从 Windows 10 (1803) 开始,Win32 应用也可以有 API 来实现原生的亚克力效果了.不过相比于 UWP 来说, ...
- C# WinForm 添加Windows Media Player 控件调试出现未能加载文件或程序集Interop.WMPLib,该怎么解决
C# WinForm 添加Windows Media Player 控件调试出现未能加载文件或程序集Interop.WMPLib如标题,在窗体中添加Windows Media Player 控件,当调 ...
- .NET在WebForm里实现类似WinForm里面TrackBar控件的效果(AJAX Control Toolkit的使用)
WinForm 里面有一个 TrackBar 控件,表示一个标准的 Windows 跟踪条,是类似于 ScrollBar 控件的可滚动控件.用这个控件可以实现很多可以实时调整的功能,比如最常见的音量调 ...
- WinForm的TreeView实现Win7 Areo效果
新建一个继承自TreeView的控件类,代码如下: using System; using System.Windows.Forms; using System.Drawing; using Syst ...
- Layered Windows窗口的半透明效果
介绍: Layered Windows是windows窗口中的一类,提供类似半透明的效果(阿尔法混合).半透明效果是字面上有能看出来的,但实际上根据MSND,该类型的窗口还能更好的支持非矩形的窗口,使 ...
随机推荐
- c# Using Settings under visual studio 2012
1.在项目属性中的Settings的设置可以通过以下方式调用 Properties.Settings.Default.(SpecifyPropertyName) 2.添加新的Settings设置文件 ...
- iOS PhotoKit框架如何获取视频文件大小
// 获取相册中的资源[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUI ...
- Leetcode 18. 4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = tar ...
- UVA1368
用一个二维数组装m个字符串,然后用一个数组装每个字符串的hamming距离.找到最小的hanming距离即可 #include<stdio.h> #include<string.h& ...
- 【JavaWeb】Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基础框架(四)
SpringSecurity(1) 其实啊,这部分我是最不想写的,因为最麻烦的也是这部分,真的是非常非常的麻烦.关于SpringSecurity的配置,让我折腾了好半天,网上的配置方式一大把,但总有一 ...
- Python 编码简单说
先说说什么是编码. 编码(encoding)就是把一个字符映射到计算机底层使用的二进制码.编码方案(encoding scheme)规定了字符串是如何编码的. python编码,其实就是对python ...
- 几种常见的Shell
Unix/Linux上常见的Shell脚本解释器有bash.sh.csh.ksh等,习惯上把它们称作一种Shell.我们常说有多少种Shell,其实说的是Shell脚本解释器. bash bash是L ...
- 深入研究HTTP协议以及部分应用
引言 工作了一段时间,都是在开发网页,自然和http打交道打得最多了,投身工作之后原来理解的东西又变得模糊,所以有必要深入探讨一下http协议的细节,也借此总结一下学习的成果. HTTP相关认识 对H ...
- ParamTest
package fourth; public class ParamTest { public static void main(String[] args) { // TODO Auto-gener ...
- bootstrap学习笔记--bootstrap概览
HTML 5 文档类型(Doctype) Bootstrap 使用了一些 HTML5 元素和 CSS 属性.为了让这些正常工作,您需要使用 HTML5 文档类型(Doctype). 因此,请在使用 B ...