在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磨砂玻璃效果的更多相关文章

  1. [转]WinForm实现win7 Aero磨砂效果介绍

    WinForm实现win7 Aero磨砂效果如下: WinForm实现win7 Aero磨砂效果代码如下: using System; using System.Collections.Generic ...

  2. Windows 7 扩展玻璃效果(Aero Glass)

    转自:http://www.cnblogs.com/gnielee/archive/2010/10/04/windows7-extend-aero-glass.html Windows 7 操作系统默 ...

  3. 【转】MFC 迅雷七窗体特效,使用DWM实现Aero Glass效果

    从Windows Vista开始,Aero Glass效果被应用在了Home Premium以上的系统中(Home Basic不具有该效果).这种效果是由DWM(Desktop Window Mana ...

  4. 窗口玻璃特效,半透明窗口,使用DWM实现Aero Glass效果

    转自:http://blog.csdn.net/ntwilford/article/details/5656633 从Windows Vista开始,Aero Glass效果被应用在了Home Pre ...

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

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

  6. C# WinForm 添加Windows Media Player 控件调试出现未能加载文件或程序集Interop.WMPLib,该怎么解决

    C# WinForm 添加Windows Media Player 控件调试出现未能加载文件或程序集Interop.WMPLib如标题,在窗体中添加Windows Media Player 控件,当调 ...

  7. .NET在WebForm里实现类似WinForm里面TrackBar控件的效果(AJAX Control Toolkit的使用)

    WinForm 里面有一个 TrackBar 控件,表示一个标准的 Windows 跟踪条,是类似于 ScrollBar 控件的可滚动控件.用这个控件可以实现很多可以实时调整的功能,比如最常见的音量调 ...

  8. WinForm的TreeView实现Win7 Areo效果

    新建一个继承自TreeView的控件类,代码如下: using System; using System.Windows.Forms; using System.Drawing; using Syst ...

  9. Layered Windows窗口的半透明效果

    介绍: Layered Windows是windows窗口中的一类,提供类似半透明的效果(阿尔法混合).半透明效果是字面上有能看出来的,但实际上根据MSND,该类型的窗口还能更好的支持非矩形的窗口,使 ...

随机推荐

  1. Mysql操作语句

    MySQL中定义数据字段的类型对你数据库的优化是非常重要的. MySQL支持多种类型,大致可以分为三类:数值.日期/时间和字符串(字符)类型. 数值类型 MySQL支持所有标准SQL数值数据类型. 这 ...

  2. Git原理及常用操作命令总结

    git原理介绍及操作 git 原理——

  3. root与普通用户的切换

    普通用户切换到root用户:sudo su - root用户切换到普通用户:su henie

  4. 在windows上部署使用Redis

    参考地址: http://keenwon.com/1275.html

  5. maven上传jar到nexus本地仓库

    一.nexus新增本地仓库 Hosted Repository:本地仓库,部署组织内部的版本内容 Proxy Repository:代理仓库,代理远程的公共仓库,如maven中央仓库 Virtual ...

  6. PHP CLI编程基础知识积累(进程、子进程、线程)

    .note-content { font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", STHeit ...

  7. p/invoke 碎片-- 对字符串的处理

    字符串在内存中的的几种风格 字符串作为参数和返回值 参考 字符串在内存中的几种风格 所谓的风格,也就是字符串在内存中的存在形式.如何存放的,占据内存的大小,还有存放顺序等.在不同的编程语言和不同的平台 ...

  8. Salesforce ADM201备考心得

    Salesforce拥有很多针对不同角色的认证考试.ADM201是面对初级管理员的认证. 考试形式是单选题和多选题(如果是多选题,题干上会提示你要多选),两个小时时间,60道题目.内容涉及管理Sale ...

  9. 387. First Unique Character in a String

    Given a string, find the first non-repeating character in it and return it's index. If it doesn't ex ...

  10. C语言结构体里的成员数组和指针

    struct test{ int i; char *p; }; struct test *str; ; char *b = "ioiodddddddddddd"; str = (s ...