看了一下,网上的教程与代码有点复杂…因此,查阅资料后,这篇文章就诞生了…
先看效果图:
虽然运行起来很漂亮..不过,当你设计的时候,就是你头痛的了…看下设计图…嘿嘿嘿嘿….
主要代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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…不过这个不在讨论范围之内..哈哈哈哈