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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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#五行代码设置透明窗体效果的主要内容,如果未能解决你的问题,请参考以下文章