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#使用handle實現(xiàn)獲取占用指定文件或文件夾的進程
很多時候,一些不知道啥進程,把你的文件給占用了,然后就沒辦法刪掉或者做其他操作,如果使用Locksmith功能,就可以實現(xiàn)快速鎖定是哪個進程在搞事情,把對應進程干掉就可以了,下面內容演示C#使用幾行代碼實現(xiàn)File?Locksmith功能,需要的朋友可以參考下2024-09-09

