C# 无边框窗体边框阴影效果的简单实现

这篇文章介绍了C# 无边框窗体边框阴影效果的简单实现,有需要的朋友可以参考一下

通过下面代码在构造函数中调用方法 SetShadow();

即可实现无边框窗体的阴影效果了

需要添加命名空间 using System.Runtime.InteropServices;

复制代码 代码如下:

private const int CS_DropSHADOW = 0x20000;
        private const int GCL_STYLE = (-26);       

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SetClassLong(IntPtr hwnd, int nIndex, int dwNewLong);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int GetClassLong(IntPtr hwnd, int nIndex);   

        private void SetShadow()
        {
            SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW);
        }

以上就是C# 无边框窗体边框阴影效果的简单实现的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 其他教程