Transparent background on winforms?(winforms透明背景?)
问题描述
我想让我的 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透明背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:winforms透明背景?
基础教程推荐
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01