通过下面代码在构造函数中调用方法 SetShadow();
即可实现无边框窗体的阴影效果了
需要添加命名空间 using System.Runtime.InteropServices;
class="code_img_closed" src="/Upload/Images/2013100615/0015B68B3C38AA5B.gif" alt="" />logs_code_hide('44733f45-3db9-471d-8c80-15e39e2d39ea',event)" src="/Upload/Images/2013100615/2B1B950FA3DF188F.gif" alt="" />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); }View Code