首页 > 代码库 > C#五行代码设置透明窗体效果

C#五行代码设置透明窗体效果

效果如图:

技术分享

 

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        Bitmap mybit;        private void Form1_Load(object sender, EventArgs e)        {            mybit = new Bitmap("mypic.png");            mybit.MakeTransparent(Color.Yellow);            this.StartPosition = FormStartPosition.CenterScreen;            this.WindowState = FormWindowState.Normal;        }        protected override void OnPaint(PaintEventArgs e)        {            e.Graphics.DrawImage((Image)mybit, new Point(0, 0));        }    }}

  

C#五行代码设置透明窗体效果