winform下實現(xiàn)win7 Aero磨砂效果實現(xiàn)代碼
更新時間:2012年03月12日 16:24:44 作者:
winform下實現(xiàn)win7 Aero磨砂效果實現(xiàn)代碼,需要的朋友可以參考下
效果圖:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using System.Runtime.InteropServices;
namespace MyWeather
{
public partial class Form1 : Form
{
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern bool DwmIsCompositionEnabled();
public Form1()
{
InitializeComponent();
}
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);
}
}
}
}

復制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using System.Runtime.InteropServices;
namespace MyWeather
{
public partial class Form1 : Form
{
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
[DllImport("dwmapi.dll", PreserveSig = false)]
static extern bool DwmIsCompositionEnabled();
public Form1()
{
InitializeComponent();
}
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);
}
}
}
}
您可能感興趣的文章:
- WinForm實現(xiàn)窗體最大化并遮蓋任務欄的方法
- C#實現(xiàn)WinForm禁止最大化、最小化、雙擊標題欄、雙擊圖標等操作的方法
- Winform實現(xiàn)鼠標可穿透的窗體鏤空效果
- Winform窗體效果實例分析
- WinForm實現(xiàn)自定義右下角提示效果的方法
- WinForm實現(xiàn)仿視頻播放器左下角滾動新聞效果的方法
- C#實現(xiàn)winform漸變效果的方法
- WinForm實現(xiàn)同時讓兩個窗體有激活效果的特效實例
- C# WinForm實現(xiàn)Win7 Aero透明效果代碼
- 用 C# Winform做出全透明的磨砂玻璃窗體效果代碼
- WinForm實現(xiàn)狀態(tài)欄跑馬燈效果的方法示例
相關文章
C#中的靜態(tài)成員、靜態(tài)方法、靜態(tài)類介紹
本文主要介紹了C#中的靜態(tài)成員、靜態(tài)方法、靜態(tài)類的基礎的使用,并做了相關的代碼演示,供初學者參考。2016-03-03C#使用SqlDataAdapter對象獲取數(shù)據(jù)的方法
這篇文章主要介紹了C#使用SqlDataAdapter對象獲取數(shù)據(jù)的方法,結(jié)合實例形式較為詳細的分析了SqlDataAdapter對象獲取數(shù)據(jù)具體步驟與相關使用技巧,需要的朋友可以參考下2016-02-02