using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace test { public partial class Form1 : Form { [DllImport("dwmapi.dll")] private static extern int DwmIsCompositionEnabled(out bool enabled); [DllImport("dwmapi.dll", PreserveSig = true)] static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins); [StructLayout(LayoutKind.Sequential)] public struct MARGINS { public int leftWidth; public int rightWidth; public int topHeight; public int bottomHeight; } public Form1() { InitializeComponent(); BackColor = Color.Black; bool DwmEnabled = false; DwmIsCompositionEnabled(out DwmEnabled); if (DwmEnabled == true) { MARGINS margin; margin.leftWidth = -1; margin.rightWidth = 0; margin.topHeight = 0; margin.bottomHeight = 0; DwmExtendFrameIntoClientArea(this.Handle, ref margin); } } } }