创建不规则窗体

 public partial class Frm_Main : Form
    {
        Bitmap bit;//声明位图对象
        public Frm_Main()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            bit = new Bitmap("font.bmp");//从指定的图像初始化Bitmap类对象
            bit.MakeTransparent(Color.Blue);//使用默认的透明颜色对Bitmap位图透明
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.DrawImage((Image)bit, new Point(0, 0));//在指定位置按指定大小绘制图片的指定部分
        }

        private void label1_Click(object sender, EventArgs e)
        {
            this.Close();//关闭当前窗体
        }
    }

效果:

posted @ 2014-02-20 16:19  蚂蚁拉车  阅读(201)  评论(0编辑  收藏  举报