winforms 上的透明背景? [英] Transparent background on winforms?
问题描述
我想让我的窗口窗体透明,所以删除了边框、控件和所有东西,只留下窗体框,然后我尝试将 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 上的透明背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!