C#实现具有Aero效果的窗体

看了一下,网上的教程与代码有点复杂…因此,查阅资料后,这篇文章就诞生了…

先看效果图:

虽然运行起来很漂亮..不过,当你设计的时候,就是你头痛的了…看下设计图…嘿嘿嘿嘿….

主要代码:

using System.Runtime.InteropServices;//引用,放在哪不用说了吧....

[DllImport("dwmapi.dll")]
public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarinset);
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
    public int Right;
    public int left;
    public int Top;
    public int Bottom;
}

private void Form1_Load(object sender, EventArgs e)
{
    this.BackgroundImage = null;
    MARGINS margins = new MARGINS();
    margins.left = -1;
    margins.Right = -1;
    margins.Top = -1;
    margins.Bottom = -1;
    IntPtr hwnd = Handle;
    int result = DwmExtendFrameIntoClientArea(hwnd, ref margins);
    this.BackColor = Color.Black;
    this.label1.Text = "大家好!我是落落。。。";
    this.label1.BackColor = Color.Transparent;
    this.label1.ForeColor = Color.White;
}

主要就是引用DLL文件…通过系统的API来实现…

只是实现了Aero效果,因为只能在Vista于Win7下可以,所以要做系统的判断与是否开启Aero…不过这个不在讨论范围之内..哈哈哈哈

[download id=”37″]

10 Replies to “C#实现具有Aero效果的窗体”

回复 zzy 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据