首先, 調用系統 API, 這裡如果要引用神馬的, 就不一一列出了, 大家自己引用一下.
複製代碼 代碼如下:[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern void DwmExtendFrameIntoClientArea
(IntPtr hwnd, ref MARGINS margins);
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern bool DwmIsCompositionEnabled();
然後重寫兩個事件: 複製代碼 代碼如下:protected override void OnLoad(EventArgs e)
{
if (DwmIsCompositionEnabled())
{
MARGINS margin = new MARGINS();
margin.Right = margin.Left = margin.Bottom = margin.Top = -1;
DwmExtendFrameIntoClientArea(this.Handle, ref margin);
}
base.OnLoad(e);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
if (DwmIsCompositionEnabled())
{
e.Graphics.Clear(Color.Black);
}
}
最後.. 木有了, F5 運行吧~