非活动形式的暗透明层 [英] Dark Transparent Layer on Inactive Form

查看:106
本文介绍了非活动形式的暗透明层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





和某些网页一样,我需要在我的VB.NET WinForm应用程序中使用一个功能。



当子窗体处于活动状态时,背景中的父窗体应该具有透明的暗层,这样用户就可以轻松地专注于活动窗体。



如果父表单本身已激活,不应出现暗层。



最初的想法是使用Panel Control但不幸的是它没有Opacity Property。



谢谢。

Hi,

Like Some Webpages, I need one feature in My VB.NET WinForm Application.

While A Child Form is Active the Parent Form in the Background should have transparent dark layer on It, So that User Can easily focus on Active Form.

If Parent form Itself got activated, that dark layer should not appear.

Initial Idea was to use Panel Control but Unfortunately It doesnt have Opacity Property.

Thank you.

推荐答案

制作透明控件 - 无闪烁 [ ^ ]



只需制作自己的控件即可,上面的教程。 .NET中没有什么可以做你想要的,至少在Win Forms中没有。 WPF因其工作原理而变得容易多了,Win Forms需要一些技巧来模拟透明度。
Making Transparent Controls - No Flickering[^]

Just make your own control that can do it, tutorial above. There's nothing out of the box in .NET that can do what you are asking, at least not in Win Forms. WPF is a lot easier because of how it works, Win Forms needs tricks to simulate transparency.


要做到这一点,你必须采取第三个窗体形式,其大小与父窗体相同,并且形式为FormBorderStyle设置为none,根据需要设置背景颜色,并将不透明度设置为30%。激活子表单时显示此表单,始终将子表单保留在顶部。关闭子表单时隐藏此新表单。
To do this you have to take third window form which size is same as Parent form and that form's FormBorderStyle set to none,set background color as you want and set opacity to 30%. Show this form when child form activated, keep child form always on top. Hide this new form when child form closed.


这篇关于非活动形式的暗透明层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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