C# WinForm实现Windows 7 Aero磨砂玻璃效果
2014-05-25 12:07
549 查看
在Vista系统之后,微软为窗体程序提供了Aero磨砂的效果,如下图。那么用C#如
何来实现这种磨砂效果呢?
代码:
这中效果的实现主要是调用了系统的dwmapi.dll。
dwmapi.dll是Microsoft Desktop Window Manager API(桌面窗口管理器DWM 的公用界面)的动态链接库,正常文件,主要用作桌面效果的api。
DWM 是一种新界面,在除 Windows Vista Home Basic 之外的所有 Windows Vista 版本中均提供 DWM 界面。所以这种效果只能在Vista之后的系统中使用。
何来实现这种磨砂效果呢?
代码:
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实现Win7 Aero透明效果代码
- Winform使用C#实现Treeview节点"正在展开..."效果
- 使用C#实现WinForm窗体的动画效果
- 使用C#实现WinForm窗体的动画效果
- winform 中实现鼠标框选效果 c#
- C# WinForm实现气泡提示效果
- c#在winform中用DataGridView实现分页效果
- C#实现具有Aero效果的窗体
- C# WinForm 实现窗体渐显效果
- C#实现WinForm窗体逐渐显示效果
- WinForm实现窗体的渐进渐出效果(C#)
- C#实现WinForm随WINDOWS服务一起启动
- 使用C#实现WINFORM窗体的动画效果
- 基于C#实现的仿windows左侧伸缩菜单效果
- 用c#实现winform的动画效果
- c# winform中实现framset的效果
- C#的winform程序下如何实现文本编辑框(TextBox)的Hint提示文字效果
- C# 分别在windows form和wpf中实现windows 7 玻璃(areo)效果
- C#实现WinForm随WINDOWS服务一起启动(转载)
- C#编写Windows服务程序 (服务端),客户端使用 消息队列 实现淘宝 订单全链路效果