我想让我的 windows 窗体透明,所以删除了边框、控件和只留下窗体框的所有内容,然后我尝试将 BackColor 和 TransparencyKey 设置为透明但它没有成功,因为 BackColor 不接受透明颜色.在四处搜索后,我在 msdn 上找到了这个:
I wanted to make my windows form transparent so removed the borders, controls and everything leaving only the forms box, then I tried to the BackColor and TransparencyKey to transparent but it didnt work out as BackColor would not accept transparent color. After searching around I found this at msdn:
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
this.TransparencyKey = BackColor;
不幸的是,它也不起作用.我仍然得到灰色或任何其他选定的颜色背景.
Unhappyly it did not work either. I still get the grey or any other selected color background.
我想做的就是让窗体透明,这样我就可以使用一个背景图像,就好像它是我的窗体一样.
All I wanted to do is to have the windows form transparent so I could use a background image that would act as if it was my windows form.
我在这里搜索了很多关于不透明度的主题,这不是我想要的,还看到了一些关于我正在尝试但尚未找到答案的方法.
I searched around here and saw many topics in regards opacity which is not what I am looking for and also saw some in regards this method I was trying but have not found an answer yet.
希望任何人都可以照亮我的道路.
Hope anyone can light my path.
更新:
问题解决后删除图片
我之前使用的方式是对BackColor使用一种百搭的颜色(没有人会使用的颜色),然后设置透明度键到那个.
The manner I have used before is to use a wild color (a color no one in their right mind would use) for the BackColor and then set the transparency key to that.
this.BackColor = Color.LimeGreen;
this.TransparencyKey = Color.LimeGreen;
这篇关于winforms透明背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!