积极答复者
C# 窗体及控件阴影效果的实现

问题
答案
-
可以通过API实现
public partial class Form1 : Form { #region 窗体边框阴影效果变量申明 const int CS_DropSHADOW = 0x20000; const int GCL_STYLE = (-26); //声明Win32 API [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); #endregion public Form1() { InitializeComponent(); SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW); //API函数加载,实现窗体边框阴影效果 } }
http://blog.csdn.net/zx13525079024- 已标记为答案 Paul Zhou 2011年5月5日 2:58
全部回复
-
可以通过API实现
public partial class Form1 : Form { #region 窗体边框阴影效果变量申明 const int CS_DropSHADOW = 0x20000; const int GCL_STYLE = (-26); //声明Win32 API [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); #endregion public Form1() { InitializeComponent(); SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW); //API函数加载,实现窗体边框阴影效果 } }
http://blog.csdn.net/zx13525079024- 已标记为答案 Paul Zhou 2011年5月5日 2:58
-
你好,
调用API是根本的方法,我想其他的方法,即使有,也是封装调用了这样的API去实现的。
Paul Zhou [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
Windows Vista及Windows 7本身窗体就是附有阴影效果的,此API是处于user32.dll中的,如果系统不兼容,就说明此系统是不支持窗体阴影效果的。
Paul Zhou [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.