如何给无边框的Form添加阴影效果?

iceMung 2013-10-11 10:52:56
求一个所有系统都能通用的效果。

下面这种在XP下完全没效果,就不用说了
        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_r(IntPtr hwnd, int nIndex);

#endregion

public Form1()
{
InitializeComponent();
SetClassLong(this.Handle, GCL_STYLE, GetClassLong_r(this.Handle, GCL_STYLE) | CS_DropSHADOW); //API函数加载,实现窗体边框阴影效果
}
...全文
333 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
iceMung 2013-10-11
  • 打赏
  • 举报
回复
引用 1 楼 bdmh 的回复:
直接在form的onpaint事件中绘制,在下边和右边绘制一定粗细的暗色线条
线和阴影还是有差别吧,有没有再好点的方法...
devmiao 2013-10-11
  • 打赏
  • 举报
回复
http://bbs.csdn.net/topics/390606049
bdmh 2013-10-11
  • 打赏
  • 举报
回复
直接在form的onpaint事件中绘制,在下边和右边绘制一定粗细的暗色线条

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧