亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C# WinForm實現(xiàn)Win7 Aero透明效果代碼

 更新時間:2014年07月03日 09:57:01   投稿:junjie  
這篇文章主要介紹了C# WinForm實現(xiàn)Win7 Aero透明效果代碼,通過調(diào)用dwmapi.dll相關(guān)方法實現(xiàn),需要的朋友可以參考下

在Vista系統(tǒng)之后,微軟為窗體程序提供了Aero磨砂的效果,如下圖。那么用C#如何來實現(xiàn)這種磨砂效果呢?

背景為我的桌面
那先上代碼吧:

[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); 
  } 
} 

這中效果的實現(xiàn)主要是調(diào)用了系統(tǒng)的dwmapi.dll。

dwmapi.dll是Microsoft Desktop Window Manager API(桌面窗口管理器DWM 的公用界面)的動態(tài)鏈接庫,正常文件,主要用作桌面效果的api。DWM 是一種新界面,在除 Windows Vista Home Basic 之外的所有 Windows Vista 版本中均提供 DWM 界面。

所以這種效果只能在Vista之后的系統(tǒng)中使用。

相關(guān)文章

最新評論