如何使表单不透明.30没有它的控件? [英] how to make form opacity .30 without its controls?

查看:67
本文介绍了如何使表单不透明.30没有它的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做具有不透明度的表单.30但完全可以看到PictureBox等窗体上的控件。



谢谢!!

解决方案

您必须使用2个表格。主窗体将不透明度设置为任何你想要的但不会有任何完全不透明的控件。



然后你创建一个具有所有不透明控件的第二个窗体并放入形成了第一个。在第二个表单上,您将使用其他未使用的颜色作为您想要透明度的背景。你设置那个颜色为TransparencyKey。



然后你必须处理移动和大小调整等事件,以便辅助表格保持在适当的位置。



您还需要处理激活,这样如果使用标准框架,主表单标题将显示为活动状态。这有点棘手,但它可以在我们的一个应用程序中完成。一方面,如果你不使用标准的标题和框架,那么你可能不需要处理它。



您可能需要使用Win API技巧取决于您的应用程序。如果我记得很清楚,在我的应用程序中,我也有半透明控件,所以我需要激活任何一个表单,但主要表现为激活,我认为我确实使用API​​(可能发送WM_MESSAGE或类似的东西) )。



如果部分不透明的部分永远不需要被激活,那么它就会简单得多,因为在这种情况下你可以在激活辅助表格时激活主表格。


C#Opacity of Picturebox [< a href =http://www.codeproject.com/Questions/198575/C-Opacity-Of-Pictureboxtarget =_ blanktitle =New Window> ^ ]



改变C#中图像的不透明度 [ ^

I want to do form having opacity .30 but controls on form such as PictureBox is visible completely.

Thank You!!

解决方案

You have to use 2 forms. The main form would have it opacity set to whatever you want but won't have any fully opaque controls.

You then create a second form having all opaque controls and put that form over the first one. On that second form, you use an otherwise unused color for the background where you want transparency. You the set that color as the TransparencyKey.

You then have to handle events like moving and sizing so that secondary form will stay at proper location.

You also need to handle activation so that you main form caption will appears to be active if you use a standard frame. This is a bit more tricky but it can be done as I have done it in one of our application. On another hand, if you don't use standard caption and frame, then you might not have to deal with that.

You might need to use Win API for some tricks depending on your application. If I remember well, in my application, I also have semi-transparent control so I need to have either form activated but the main one to appears as activated and I think I do use API for that (probably sending a WM_MESSAGE or something like that).

If the partially opaque part never need to be activated, then it is much simpler as in that case you can always activate main form when the secondary form is activated.


C# Opacity Of Picturebox[^]

Change Opacity of Image in C#[^]


这篇关于如何使表单不透明.30没有它的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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