zoukankan      html  css  js  c++  java
  • 创建非矩形窗体

    实现效果:

      

     知识运用:

      通过重写窗体的OnPaint方法 在其中对窗体进行重绘 并使用透明色将窗体设置为透明来实现

      OnPaint方法: 用来从新绘制窗体图像 

      protected override void OnPaint(PaintEventArgs e) //painteventargs为Paint事件提供数据

      Bitmap类的MakeTransparent方法: 使用指定颜色对位图进行透明  

         public void MakeTransparent(Color transparentColor)  //transparentColor:Color结构 表是使之透明的颜色

      this.BackColor = System.Drawing.SystemColors.Control;

      this.TransparencyKey = System.Drawing.SystemColors.Control;

    实现代码:  

            private void Form1_Load(object sender, EventArgs e)
            {
                bit = new Bitmap(Properties.Resources.bit);//从指定的图像初始化Bitmap对象
                bit.MakeTransparent(Color.Black);       //使用指定的颜色对Bitmap位图透明
            }
            protected override void OnPaint(PaintEventArgs e)
            {
                e.Graphics.DrawImage(bit, new Point(0, 0));   //在窗体上绘制图片
            }
    
  • 相关阅读:
    小球掉落
    String当中与转换相关常用的方法有
    字符串的截取方法
    golang 管道
    golang--协程之间通信的方式
    golang--goroutine
    go 时间操作
    吉格勒定理
    检视阅读
    git branch -a发现分支显示不全
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10111666.html
Copyright © 2011-2022 走看看