首页
关于
统计
加速器
Search
1
网址自动推送百度API源码(PHP源码)
407 阅读
2
宝塔LINUX企业永久付费破解版 所有专业版企业版插件免费使用!
270 阅读
3
宝塔面板7.7.0版本原版安装+升级脚本
245 阅读
4
宝塔面板插件破解方法
187 阅读
5
召唤神龙(源码)
176 阅读
新闻中心
WinForm
WinForm成品
WinForm源码
WinForm代码段
E语言
E成品
E源码
WEB
PHP代码
web源码
建站程序
网站文章
BT
网络安全
软件工具
技术教程
活动线报
闲聊
登录
Search
标签搜索
宝塔面板
源码
PHP
BT
百度
Typecho
IP
C#进程守护
进程守护
Winform进程守护
宝塔企业版
宝塔专业版
监控报表
建站程序
Winform除法
winform窗体透明背景实现
网络检测
宝塔面板卸载
去掉index.php
Winform向服务器请求图片
Root's small world
累计撰写
71
篇文章
累计收到
135
条评论
今日撰写
0
篇文章
首页
栏目
新闻中心
WinForm
WinForm成品
WinForm源码
WinForm代码段
E语言
E成品
E源码
WEB
PHP代码
web源码
建站程序
网站文章
BT
网络安全
软件工具
技术教程
活动线报
闲聊
页面
关于
统计
加速器
用户登录
登录
搜索到
1
篇与
winform窗体透明背景实现
的结果
2021-12-25
winform窗体透明背景实现
因为winform Form窗体的局限性,不允许设置背景色为transparent。所以不能实现透明背景。这里有一个取巧的方法(截Form后的背景)。首先来看下实现效果: 想要实现半透明效果只要加个panel ,将panel设置为背景色透明,然后加个遮罩图片就可以了。 以下附上实现代码:using System; using System.Drawing; using System.Windows.Forms; namespace WindowsTrans { public partial class Form1 : Form { private Color tr_color = Color.Transparent; private bool b_start = false; bool[] b_visible = null; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { SetBackgroundImageTransparent(); } private void SetBackgroundImageTransparent() { Point pt = this.PointToScreen(new Point(0, 0)); Bitmap b = new Bitmap(this.Width, this.Height); using (Graphics g = Graphics.FromImage(b)) { g.CopyFromScreen(pt, new Point(), new Size(this.Width, this.Height)); } this.BackgroundImage = b; } private void BeginSet() { tr_color = this.TransparencyKey; b_start = true; } private void Setting() { if (b_start) { b_visible = new bool[Controls.Count]; for (int i = 0; i < Controls.Count; i++) { b_visible[i] = Controls[i].Visible; Controls[i].Visible = false; } BackgroundImage = null; BackColor = Color.White; b_start = false; this.TransparencyKey = Color.White; } } private void EndSet() { SetBackgroundImageTransparent(); this.TransparencyKey = tr_color; for (int i = 0; i < Controls.Count; i++) { Controls[i].Visible = b_visible[i]; } b_start = false; } private void Form1_Resize(object sender, EventArgs e) { Setting(); } private void Form1_ResizeBegin(object sender, EventArgs e) { BeginSet(); } private void Form1_ResizeEnd(object sender, EventArgs e) { EndSet(); } private void Form1_Move(object sender, EventArgs e) { Setting(); } } }
2021年12月25日
61 阅读
0 评论
0 点赞