[DllImport("dwmapi.dll")]
private static extern void DwmIsCompositionEnabled(ref int enabledptr);
[DllImport("dwmapi.dll")]
private static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS margin);
Step Two:定义区域这个结构体
public struct MARGINS
{
public int m_Left;
public int m_Right;
public int m_Top;
public int m_Buttom;
};
Step Three:在构造方法中加入如下代码:
//判断是否Vista及以上的系统
if (System.Environment.OSVersion.Version.Major >= 6)
{
DwmIsCompositionEnabled(ref en); //检测Aero是否为打开
if (en > 0)
{
DwmExtendFrameIntoClientArea(this.Handle, ref mg); //透明