通過下面代碼在構造函數中調用方法 SetShadow();
即可實現無邊框窗體的陰影效果了
需要添加命名空間 using System.Runtime.InteropServices;
[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);
}
新聞熱點
疑難解答