先看下效果

纯透明的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(, , width, height);
this.graphics.DrawImage(this.BackgroundImage, recModel);
}
else if (this.ForeColor != Color.Transparent)
{
this.graphics.Clear(this.ForeColor);
} } }

最新文章

  1. iOS-提高iOS开发效率的方法和工具
  2. 【ZJOI2013】k大数查询 BZOJ 3110
  3. 【GOF23设计模式】装饰模式
  4. haartraining生成.xml过程
  5. C++之路起航——标准模板库(list)
  6. POJ 1287 Networking (最小生成树)
  7. Object c中的alloc和init问题
  8. php中函数不确定参数个数时获取所有参数
  9. html加载与脚本运行中,由于html未完全加载而导致脚本找不到dom元素无法执行事件
  10. ZOJ 3483 简单if-else
  11. 中文里带半角空格导致的Text换行问题[Unity]
  12. 【一天一道LeetCode】#118. Pascal's Triangle
  13. mssql sqlserver updatetext关键字应用简介说明
  14. 【从零开始自制CPU之学习篇07】最简单的ALU—全加器
  15. python xpath学习
  16. F#周报2019年第10期
  17. map,set和weakmap,weakset
  18. Android源代码下载以及异常查找网站推荐
  19. MyEclipse Maven Tomcat
  20. Spring 一二事(6) - IOC MVC 简易搭建

热门文章

  1. Fiddler快速入门(还有一个功能就是不经过网络,直接模拟一个响应返回给客户端)
  2. git安装使用详解
  3. IT企业级应?开发模式演化
  4. 将普通java工程转换成maven工程
  5. 机器学习: t-Stochastic Neighbor Embedding 降维算法 (一)
  6. 机器学习编程接口(api)设计(oop 设计)
  7. tar.gz文件命名及压缩解压方法
  8. 微软输入法TSF SampleIME 代码浅说
  9. flash导出正常清晰(无色差)GIF图片
  10. Git撤销对远程仓库的push&commit提交