博客
关于我
c#透明panel
阅读量:411 次
发布时间:2019-03-06

本文共 1711 字,大约阅读时间需要 5 分钟。

先看下效果

纯透明的pane,然后设置一个半透明的图片,可以看出来显示了父控件的button

看代码

public partial class PanelEx : Panel    {        protected Graphics graphics;        protected override CreateParams CreateParams        {            get            {                CreateParams cp = base.CreateParams;                cp.ExStyle |= 0x00000020; // 实现透明样式                return cp;            }        }        public PanelEx()        {            InitializeComponent();            this.BackColor = Color.Transparent;            this.ForeColor = Color.Transparent;        }        protected override void OnPaintBackground(PaintEventArgs pevent)        {        }        protected override void OnPaint(PaintEventArgs e)        {            base.OnPaint(e);            this.graphics = e.Graphics;            this.graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;            this.graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;            this.graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;            this.graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;            this.graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;            if (this.BackgroundImage != null)            {                int width = this.Width;                int height = this.Height;                Rectangle recModel = new Rectangle(0, 0, width, height);                this.graphics.DrawImage(this.BackgroundImage, recModel);            }            else if (this.ForeColor != Color.Transparent)            {                this.graphics.Clear(this.ForeColor);            }        }    }
View Code

 

转载地址:http://tnvkz.baihongyu.com/

你可能感兴趣的文章
mysql select, from ,join ,on ,where groupby,having ,order by limit的执行顺序和书写顺序
查看>>
MySQL Server 5.5安装记录
查看>>
mysql server has gone away
查看>>
mysql slave 停了_slave 停止。求解决方法
查看>>
MySQL SQL 优化指南:主键、ORDER BY、GROUP BY 和 UPDATE 优化详解
查看>>
MYSQL sql语句针对数据记录时间范围查询的效率对比
查看>>
mysql sum 没返回,如果没有找到任何值,我如何在MySQL中获得SUM函数以返回'0'?
查看>>
mysql Timestamp时间隔了8小时
查看>>
Mysql tinyint(1)与tinyint(4)的区别
查看>>
mysql union orderby 无效
查看>>
mysql v$session_Oracle 进程查看v$session
查看>>
mysql where中如何判断不为空
查看>>
MySQL Workbench 使用手册:从入门到精通
查看>>
mysql workbench6.3.5_MySQL Workbench
查看>>
MySQL Workbench安装教程以及菜单汉化
查看>>
MySQL Xtrabackup 安装、备份、恢复
查看>>
mysql [Err] 1436 - Thread stack overrun: 129464 bytes used of a 286720 byte stack, and 160000 bytes
查看>>
MySQL _ MySQL常用操作
查看>>
MySQL – 导出数据成csv
查看>>
MySQL —— 在CentOS9下安装MySQL
查看>>