zoukankan      html  css  js  c++  java
  • c#透明panel

    先看下效果

    纯透明的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
  • 相关阅读:
    9.13 h5日记
    9.12 h5日记
    9.11 h5日记
    9.10 h5日记
    H5笔记周记
    ASP.NET-GridView之表头设计
    论执行力
    BS总结篇­
    花样年纪的记录(一)
    Nginx+ISS+Redis实现完美负载均衡
  • 原文地址:https://www.cnblogs.com/bfyx/p/9466259.html
Copyright © 2011-2022 走看看