如何添加阴影周围无边框形式? [英] How can I add a shadow around a form with no border?

查看:183
本文介绍了如何添加阴影周围无边框形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何添加一个完整的阴影围绕一个无国界的形式,使用的WinForms。我期待在添加阴影围绕表格的所有四边。

I am trying to figure out how to add a full shadow around a borderless form, using WinForms. I am looking at adding a shadow around all four sides of the form.

我已经使用将dropShadow类,虽然它只是增加了阴影底部和右侧边角尝试。

I have tried using the DropShadow class, although it only adds the shadow to the bottom and right side corners.

我已经看到了这个问题问过很多次,我的搜索​​,但没有我凸轮后,遇到了四面答案。

I have seen this question asked many times before in my searches but nothing I cam upon had an answer for all four sides.

我是用我的解决方案C#和VB.net语言,因此对于任何一种语言的任何帮助将是一个很大的帮助。

I am using both C# and VB.net languages in my solution so any help regarding either language would be a big help.

推荐答案

您将不得不手动绘制这一点。我做了类似的东西了闪屏之前,我想。您需要从窗体的客户区决定阴影的偏移,要么创建一个容器(更容易布局明智的)来承载它的子控件或者如果你需要动态阴影大小编程方式重新定位自己的客户端矩形,然后绘制边框。如果没有记错,你会使用alpha混合+一个LinearGradientBrush褪色的阴影透明度到边缘获得最好的效果。

You are going to have to manually draw this. I have done something similar before with a splash screen, I think. You need to decide the offset of the shadow from the client area of the form and either create a container (easier layout wise) to host its constituent controls or redefine its client rectangle programmatically if you need dynamic shadow size, and then draw your border. If memory serves, you will get the best results using alpha blending + lineargradientbrush to fade the shadow transparency out to the edges.

这篇关于如何添加阴影周围无边框形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆