Rationale: Overriding the current form OnPaint method
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace SpecialSharpWindows
{
public partial class Form1 : Form
{
Bitmap bit;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
bit = new Bitmap("heart.bmp");
bit.MakeTransparent(Color.Blue);
}
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();
}
}
}
The interface design is attached:
Code generated #region the Windows forms Designer
///<summary>
///Designer supports the desired method-do not
///use the Code Editor to modify the contents of this method.
///</summary>
private void InitializeComponent ()
{
This.label1 = new System.wind oWS. Forms.label ();
this. SuspendLayout ();
//
//Label1
//
This.label1.BackColor = System.Drawing.Color.Transparent;
This.label1.Location = new System.Drawing.Point (280, 42);
This.label1.Name = "Label1";
This.label1.Size = new System.Drawing.Size (17, 16);
This.label1.TabIndex = 0;
This.label1.Click + = new System.EventHandler (This.label1_click);
//
//Form1
//
this. Autoscaledimensions = new System.Drawing.SizeF (6F, 12F);
this. AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this. BackColor = System.Drawing.SystemColors.Control;
this. ClientSize = new System.Drawing.Size (393, 317);
this. Controls.Add (This. Label1);
this. FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this. Name = "Form1";
this. StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this. Text = "Font form";
this. TransparencyKey = System.Drawing.SystemColors.Control;
this. Load + = new System.EventHandler (this. Form1_Load);
this. ResumeLayout (FALSE);
}
#endregion
Article Source: http://www.cnblogs.com/ziyiFly/archive/2008/09/11/1288849.html