How can I add a shadow around a form with no borde

2019-02-25 17:21发布

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.

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.

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

1条回答
唯我独甜
2楼-- · 2019-02-25 18:05

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.

查看更多
登录 后发表回答