软件编程
位置:首页>> 软件编程>> C#编程>> C# 无边框窗体边框阴影效果的简单实现

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

  发布时间:2021-12-06 23:41:43 

标签: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);
        }

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com