using System;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;
public class Test
{
static void Main ()
{
TestForm form = new TestForm ();
Application.Run (form);
}
}
public class TestForm : Form
{
public TestForm ()
{
Button button = new Button ();
button.Parent = this;
button.Location = new Point (5, 5);
button.Text = "Click me";
button.Click += OnButtonClick;
}
void OnButtonClick (object o, EventArgs args)
{
Graphics graphics = CreateGraphics ();
Point point = new Point (0, 0);
string str = "User click.";
graphics.DrawString (str, Font, new SolidBrush (ForeColor),
point);
Thread.Sleep (1000 * 10); // This allows the text to appear in the form
graphics.FillRectangle (new SolidBrush (BackColor),
new RectangleF (point, graphics.MeasureString (str, Font))); // 'Clean' form
graphics.Dispose ();
}
}